Re: [Boost-bugs] [Boost C++ Libraries] #3747: Serialization code speculate in order of static initialization

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3747: Serialization code speculate in order of static initialization
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-03-31 16:17:32


#3747: Serialization code speculate in order of static initialization
--------------------------------------------------+-------------------------
  Reporter: Runar Undheim <r.undheim@…> | Owner: ramey
      Type: Bugs | Status: closed
 Milestone: Boost 1.43.0 | Component: serialization
   Version: Boost 1.41.0 | Severity: Showstopper
Resolution: fixed | Keywords: serialization static order
--------------------------------------------------+-------------------------
Changes (by ramey):

  * status: reopened => closed
  * resolution: => fixed

Comment:

 OK, I added serializationRegistration.cpp to my project.

 I hadn't done this because it all the functions were inlined and no other
 file was necessary for the build.

 In any case, I think I've gotten to the bottom of this. Refer to the
 discussion in the serialization documentation under

 Reference/serializable concept/class serialization traits/export key.

 I'm referring to the documentation currently in the release branch. I
 don't remember when I wrote this but it might not be part of the 1.42
 package. If not it should be in the next release.

 the ..EXPORT has always been a source of problems. Originally, it
 performed two functions: Assigment of an external string "export key" and
 instantiation of serialization code for classes otherwise not referenced.
 This seemed OK. But when people started to use DLLs, the mixing of two
 functions created problems. If the EXPORT was in the header, the same
 code was re-instantiated across modules. If the ...EXPORT was in the
 *.cpp one got unregistered class exceptions. The solution was to make two
 macros: One for the header BOOST_CLASS_EXPORT_KEY and one for the *.cpp :
 BOOST_CLASS_EXPORT_IMPLEMENT. The original behavior was preserved by
 making BOOST_CLASS_EXPORT just the combination of the two.

 So in your case, where you want to separate the implemenation from the
 declaration (not a bad idea) then the best would be to use
 BOOST_CLASS_EXPORT_IMPLEMENT in the *.cpp and BOOST_CLASS_EXPORT_KEY in
 the header as described in the documentation.

 I think this will resolve the questions you've posed here.

 Thanks for your patience.

 Robert Ramey

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3747#comment:15>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC