Boost C++ Libraries: Ticket #3747: Serialization code speculate in order of static initialization https://svn.boost.org/trac10/ticket/3747 <p> I have a lot of classes that need serialization, and the serialization code are split in several cpp-files. This will give an registration exception during export. See attached files for a simple example that give problem. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3747 Trac 1.4.3 Runar Undheim <r.undheim@…> Thu, 10 Dec 2009 14:32:22 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main.cpp</span> </li> </ul> Ticket Runar Undheim <r.undheim@…> Thu, 10 Dec 2009 14:32:40 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">SerializationBase.cpp</span> </li> </ul> Ticket Runar Undheim <r.undheim@…> Thu, 10 Dec 2009 14:32:52 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">SerializationBase.hpp</span> </li> </ul> Ticket Runar Undheim <r.undheim@…> Thu, 10 Dec 2009 14:33:06 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">serializationDerived.cpp</span> </li> </ul> Ticket Runar Undheim <r.undheim@…> Thu, 10 Dec 2009 14:33:26 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">SerializationDerived.hpp</span> </li> </ul> Ticket Robert Ramey Thu, 10 Dec 2009 17:35:36 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">SerializationBase.2.cpp</span> </li> </ul> Ticket Robert Ramey Thu, 10 Dec 2009 17:36:05 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">SerializationBase.2.hpp</span> </li> </ul> Ticket Robert Ramey Thu, 10 Dec 2009 17:36:33 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">serializationDerived.2.cpp</span> </li> </ul> Ticket Robert Ramey Thu, 10 Dec 2009 17:37:07 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">SerializationDerived.2.hpp</span> </li> </ul> Ticket Robert Ramey Thu, 10 Dec 2009 17:37:35 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3747#comment:1 https://svn.boost.org/trac10/ticket/3747#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> I looked at this and made some changes in your files. The reasons why the changes are necessary might seem non-obvious at first, but I'm sure a closer reading of the documentation regarding the serialization of data through a pointers to base classes will help clarify things. </p> <p> Robert Ramey </p> Ticket Runar Undheim <r.undheim@…> Fri, 11 Dec 2009 06:34:01 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main.2.cpp</span> </li> </ul> Ticket Runar Undheim <r.undheim@…> Fri, 11 Dec 2009 06:34:22 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">SerializationBase.3.cpp</span> </li> </ul> Ticket Runar Undheim <r.undheim@…> Fri, 11 Dec 2009 06:34:42 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">SerializationBase.3.hpp</span> </li> </ul> Ticket Runar Undheim <r.undheim@…> Fri, 11 Dec 2009 06:35:01 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">serializationDerived.3.cpp</span> </li> </ul> Ticket Runar Undheim <r.undheim@…> Fri, 11 Dec 2009 06:35:53 GMT attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">SerializationDerived.3.hpp</span> </li> </ul> Ticket Runar Undheim <r.undheim@…> Fri, 11 Dec 2009 07:03:54 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/3747#comment:2 https://svn.boost.org/trac10/ticket/3747#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> <p> Thanks for a very fast reply. I tried to make the example as small as possible and attached files that doesn't work in 1.40 neither. I'm sorry. I have now attached new files. This code work with boost version 1.40 but not with version 1.41. The compiler that I use are VisualC++ 2005. </p> <p> I got an exception from basic_oarchive.cpp line 331 (archive_exception(archive_exception::unregistered_class)). </p> <p> If I add both registration (BOOST_CLASS_EXPORT) in the main.cpp it works nice, but not if both registration are in one of the other files. </p> <p> Runar </p> Ticket Robert Ramey Fri, 11 Dec 2009 16:48:14 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3747#comment:3 https://svn.boost.org/trac10/ticket/3747#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> Question: I attached and updated set of files. These were the same as your original ones with a couple of changes to fix obvious blunders. I built and ran this program with on my msvc 7.1 system with the latest trunk. Did you actually try to use the files I sent you? That is, does the exact test which passes on my setup fail on yours? </p> <p> Robert Ramey </p> <p> Just perusing serializationDerived.3.cpp shows an obvious error in the understanding of "export". The main function of BOOST_CLASS_EXPORT(..) is to instatiate code for each Archive class included. Hence, it makes no sense to ..EXPORT in the same file with no "#include ...archive.hpp. Go back and study the documentation and the examples. If the documentation isn't clear enough, I'd be happy to consider a patch submitted to the documentation. </p> <p> Robert Ramey </p> <p> PS. The fact that something may have worked in 1.39 is not really helpful. I can't test that version now and sometimes things that shouldn't work in fact do work. RR </p> Ticket Runar Undheim <r.undheim@…> Mon, 14 Dec 2009 08:19:33 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/3747#comment:4 https://svn.boost.org/trac10/ticket/3747#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> <blockquote class="citation"> <p> Did you actually try to use the files I sent you? </p> </blockquote> <p> Yes </p> <blockquote class="citation"> <p> That is, does the exact test which passes on my setup fail on yours? </p> </blockquote> <p> No, but with a little change in the code I mange to get the problem. I updated the main class to also keep an instance of the Object class: </p> <pre class="wiki">#include "serializationDerived.hpp" class Main : public Base { friend class boost::serialization::access; template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version) { ar &amp; boost::serialization::base_object&lt;Base&gt;(*this); ar &amp; m_objects; ar &amp; m_object; } public: std::vector&lt;Base*&gt; m_objects; Object m_object; Main( ) { } }; </pre><p> This code create problem. If I move both BOOST_CLASS_EXPORT registration into the main.cpp, then it works again. So it seems that the error is dependent on the order that the static classes are initiated.<br /> 1) Should it be allowed to both serialize an instance and a pointer to a class?<br /> 2) Should it be possible to split the serialization classes into different files?<br /> </p> <blockquote class="citation"> <p> Just perusing serializationDerived.3.cpp shows an obvious error ... </p> </blockquote> <p> serializationDerived.3.cpp include the export files through the header file serializationDerived.hpp. </p> <blockquote class="citation"> <p> PS. The fact that something may have worked... </p> </blockquote> <p> If the code worked in 1.40 it would reduce the number of blunders in the code. But we should find out if it is a bug or just a side effect. If it is a side effect is should probably be mention in the documentation: Differences from Boost 1.40. </p> <p> Runar Undheim </p> Ticket Robert Ramey Mon, 14 Dec 2009 23:26:56 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3747#comment:5 https://svn.boost.org/trac10/ticket/3747#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> The code: </p> <pre class="wiki">#include "serializationBase.hpp" BOOST_CLASS_EXPORT(Object) </pre><p> will not and cannot do anything without including the archive classes for which the data types are to be exported. <a class="missing wiki">ReCheck</a> the documentation. If the documentation is unclear on this point, feel free to submit a revision to it. </p> <p> Robert Ramey </p> Ticket Runar Undheim <r.undheim@…> Tue, 15 Dec 2009 07:17:21 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/3747#comment:6 https://svn.boost.org/trac10/ticket/3747#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> <p> "serilizationbase.hpp" include these files: </p> <pre class="wiki">#include &lt;boost/archive/text_oarchive.hpp&gt; #include &lt;boost/archive/text_iarchive.hpp&gt; #include &lt;boost/archive/binary_oarchive.hpp&gt; #include &lt;boost/archive/binary_iarchive.hpp&gt; #include &lt;boost/serialization/export.hpp&gt; #include &lt;boost/serialization/base_object.hpp&gt; </pre><p> So what archive classes are missing? I have to know the error before I can update the documentation. </p> <p> But I manage to reproduce the bug with the updated files you sent me with a small change. So you could just try with your own files with a little change in the Main class: </p> <pre class="wiki">#include "serializationDerived.hpp" class Main : public Base { friend class boost::serialization::access; template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version) { ar &amp; boost::serialization::base_object&lt;Base&gt;(*this); ar &amp; m_objects; ar &amp; m_object; } public: std::vector&lt;Base*&gt; m_objects; Object m_object; Main( ) { } }; </pre><p> Did you try that?<br /> 1) Should it be allowed to both serialize an instance and a pointer to a class?<br /> 2) Should it be possible to split the serialization classes into different files?<br /> If the answer to 1 and 2 are yes then it seems to be a bug at least when compiling with msvc 8.0. </p> <p> Runar Undheim </p> Ticket Robert Ramey Wed, 30 Dec 2009 18:07:18 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3747#comment:7 https://svn.boost.org/trac10/ticket/3747#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> I'm sorry I just can't address this. It's too time consuming to do this all over again. </p> <p> Robert Ramey </p> Ticket Runar Undheim <r.undheim@…> Mon, 04 Jan 2010 07:30:52 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/3747#comment:8 https://svn.boost.org/trac10/ticket/3747#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">wontfix</span> </li> </ul> <p> I'm a little disappointed. After your first answer you have not answered none of my question, and I have tried to answer yours. You tell me that the last files "will not and cannot do anything without including the archive classes for which the data types are to be exported" </p> <p> The files include these files through other includes: </p> <pre class="wiki">#include &lt;boost/archive/text_oarchive.hpp&gt; #include &lt;boost/archive/text_iarchive.hpp&gt; #include &lt;boost/archive/binary_oarchive.hpp&gt; #include &lt;boost/archive/binary_iarchive.hpp&gt; #include &lt;boost/serialization/export.hpp&gt; #include &lt;boost/serialization/base_object.hpp&gt; </pre><p> So I ask again: What archive classes are missing? </p> <p> I also manage to get the problem with your files that should be correct. I just added the Object class as a member to the Main class. So please take some time to look into this bug. </p> <p> Runar Undheim </p> Ticket Runar Undheim <r.undheim@…> Fri, 12 Feb 2010 08:27:04 GMT <link>https://svn.boost.org/trac10/ticket/3747#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3747#comment:9</guid> <description> <p> The problem still exist with boost 1.42.0 </p> <p> Runar Undheim </p> </description> <category>Ticket</category> </item> <item> <author>Runar Undheim <r.undheim@…></author> <pubDate>Fri, 26 Mar 2010 14:00:07 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/3747 https://svn.boost.org/trac10/ticket/3747 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">SerializationBug1.zip</span> </li> </ul> <p> Project with different in order of static initialization </p> Ticket Runar Undheim <r.undheim@…> Fri, 26 Mar 2010 14:07:34 GMT summary, severity, milestone changed; keywords set https://svn.boost.org/trac10/ticket/3747#comment:10 https://svn.boost.org/trac10/ticket/3747#comment:10 <ul> <li><strong>keywords</strong> serialization static order added </li> <li><strong>summary</strong> <span class="trac-field-old">Not possible to split derived classes in several files</span> → <span class="trac-field-new">Serialization code speculate in order of static initialization</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Showstopper</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.42.0</span> → <span class="trac-field-new">Boost 1.43.0</span> </li> </ul> <p> Use project from attached zip-file (SerializationBug1.zip). If I set CLASS_EXPORT_IN_MAIN define to 0 then it fails. It I set it to 1 then everything works nicely. This define changes the file where the classes are registered: </p> <p> In main.cpp: </p> <pre class="wiki">#include "SerializationClasses.hpp" #if CLASS_EXPORT_IN_MAIN BOOST_CLASS_EXPORT(Object) BOOST_CLASS_EXPORT(Main) #endif </pre><p> In serializationRegistration.cpp: </p> <pre class="wiki">#include "serializationClasses.hpp" #if !CLASS_EXPORT_IN_MAIN BOOST_CLASS_EXPORT(Object) BOOST_CLASS_EXPORT(Main) #endif </pre><p> The only difference I can see is the order of the static initialization. </p> <p> When code fail (order_of_static_registration_fail.txt): </p> <pre class="wiki">boost::serialization::singleton&lt;boost::archive::detail::oserializer&lt;boost::archive::text_oarchive,Main&gt; &gt;::instance''(void) boost::serialization::singleton&lt;boost::serialization::extended_type_info_typeid&lt;Main&gt; &gt;::instance''(void) boost::serialization::singleton&lt;boost::serialization::void_cast_detail::void_caster_primitive&lt;Main,Base&gt; &gt;::instance''(void) ... </pre><p> When code is working (order_of_static_registration_ok.txt): </p> <pre class="wiki">boost::archive::detail::`anonymous namespace'::init_guid&lt;Object&gt;::g''(void) boost::archive::detail::`anonymous namespace'::init_guid&lt;Main&gt;::g''(void) boost::serialization::singleton&lt;boost::archive::detail::`anonymous namespace'::guid_initializer&lt;Object&gt; &gt;::instance''(void) ... </pre><p> The code seems to speculate in the order of the static initialization. The code should be updated to handle when static initialization come in this order. </p> <p> Runar Undheim </p> Ticket Robert Ramey Mon, 29 Mar 2010 21:11:41 GMT <link>https://svn.boost.org/trac10/ticket/3747#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3747#comment:11</guid> <description> <p> What is the problem? </p> <p> Why should static initialization be in some particular order? </p> <p> What is the error here? </p> <p> I unzipped the files. and tried to compile and got </p> <p> serializationRegistration.cpp Linking to lib file: boost_serialization-vc71-mt-gd-1_42.lib Linking to lib file: boost_serialization-vc71-mt-gd-1_42.lib Linking to lib file: boost_serialization-vc71-mt-gd-1_42.lib c:\<a class="missing wiki">BoostRelease</a>\libs\serialization\test\<a class="missing wiki">SerializationClasses</a>.hpp(18) : error C2470: 'abstract' : looks like a function definition, but there is no formal parameter list; skipping apparent body c:\<a class="missing wiki">BoostRelease</a>\libs\serialization\test\<a class="missing wiki">SerializationClasses</a>.hpp(27) : error C2504: 'Base' : base class undefined c:\<a class="missing wiki">BoostRelease</a>\libs\serialization\test\<a class="missing wiki">SerializationClasses</a>.hpp(35) : error C2504: 'Base' : base class undefined </p> <p> I just don't know what I'm supposed to do with this. </p> <p> Robert Ramey </p> </description> <category>Ticket</category> </item> <item> <author>Runar Undheim <r.undheim@…></author> <pubDate>Tue, 30 Mar 2010 07:44:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3747#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3747#comment:12</guid> <description> <p> <em>What is the problem?</em><br /> The BOOST_CLASS_EXPORT does not register classes correctly. I got an exception from basic_oarchive.cpp line 351 (boost 1.42) (archive_exception(archive_exception::unregistered_class)) during export. This message only come when CLASS_EXPORT_IN_MAIN is 0. I got a pointer to serialization::extended_type_info (variable eti), but the m_key is NULL. </p> <p> <em>Why should static initialization be in some particular order?</em><br /> It should not, the order is decided by the compiler. But why does the code work when the static initialization is in one particular order and not in an other order? The serialization code should handle any order. </p> <p> <em>I unzipped the files. and tried to compile and got ...</em> <br /> I am sorry, but I work with VisualC++ 2005 where abstract is a legal keyword. But you could just remove the abstract behind "class Base". It does not matter on how the code is working. I think it may be impossible to reproduce this on other compilers, because it is the order of the static initialization that cause the problem. I have only tested with Visual C++ 2008 and Visual C++ 2010 RC, but I got the same problem there. </p> <p> I set a break point in constructor to extended_type_info. When CLASS_EXPORT_IN_MAIN is 0 the key is always NULL pointer. When CLASS_EXPORT_IN_MAIN is 1 I got a valid key. </p> <pre class="wiki"> extended_type_info_typeid() : typeid_system::extended_type_info_typeid_0(get_key()) { type_register(typeid(T)); key_register(); } const char * get_key() const { return boost::serialization::guid&lt;T&gt;(); } </pre><p> The extended_type_info_typeid::get_key function speculate in that the boost::serialization::guid&lt;T&gt;() is registered. </p> <p> So this static function: </p> <pre class="wiki">boost::serialization::singleton&lt;boost::archive::detail::oserializer&lt;boost::archive::text_oarchive,Main&gt; &gt;::instance''(void) </pre><p> speculate that this function is called before: </p> <pre class="wiki">boost::archive::detail::`anonymous namespace'::init_guid&lt;Main&gt;::g''(void) </pre><p> This is not always the case. At least not with Visual Studio C++ 2005 and newer. See order_of_static_registration_fail.txt for order of static initialization when the code fail and see order_of_static_registration_ok.txt for order when everything works nice. </p> <p> Runar Undheim </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Tue, 30 Mar 2010 15:55:54 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3747#comment:13 https://svn.boost.org/trac10/ticket/3747#comment:13 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <pre class="wiki">#include "SerializationClasses.hpp" #if CLASS_EXPORT_IN_MAIN BOOST_CLASS_EXPORT(Object) BOOST_CLASS_EXPORT(Main) #endif int _tmain(int argc, _TCHAR* argv[]) { Main mainObj; std::ofstream ofs("test.txt", std::ios_base::out); boost::archive::text_oarchive oa(ofs); // write class instance to archive oa &lt;&lt; mainObj; return 0; } </pre><p> if CLASS_EXPORT_IN_MAIN == 0 this code will fail with unregistered class. </p> <p> This is correct behavior. Derived pointer types must be either explicitly registered with register type OR with ...EXPORT. </p> <p> If EXPORT is used, it must be in the same module as the #include ...archive.hpp" is included. This will provoke instantiation of code for types not explicitly referred to. </p> <p> Looks like everything is working as it is designed to work. Take another look a the documentation. If it's not clear on this point, feel free to suggest improved wording. </p> <p> Robert Ramey </p> Ticket Runar Undheim <r.undheim@…> Wed, 31 Mar 2010 06:20:36 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/3747#comment:14 https://svn.boost.org/trac10/ticket/3747#comment:14 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> <p> By you answer, it does not seems to me that you have understood my problem. Could you please take another look (make sure you include serializationRegistration.cpp in your project)? </p> <p> If CLASS_EXPORT_IN_MAIN is 0 then the registration is done inside serializationRegistration.cpp. So this define only move the registration between main.cpp and serializationRegistration.cpp. It does not remove the registration: </p> <pre class="wiki">#include "serializationClasses.hpp" #if !CLASS_EXPORT_IN_MAIN BOOST_CLASS_EXPORT(Object) BOOST_CLASS_EXPORT(Main) #endif </pre><p> I don't see anything in the documentation telling me that BOOST_CLASS_EXPORT must be in a special file, but it must be after the include of archive class headers. </p> <p> Please look into order_of_static_registration_fail.txt and order_of_static_registration_ok.txt. You see that the files contains the same number of static initializations, but that the order of the function calls are different. </p> <p> Runar Undheim </p> Ticket Robert Ramey Wed, 31 Mar 2010 16:17:31 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3747#comment:15 https://svn.boost.org/trac10/ticket/3747#comment:15 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> OK, I added serializationRegistration.cpp to my project. </p> <p> I hadn't done this because it all the functions were inlined and no other file was necessary for the build. </p> <p> In any case, I think I've gotten to the bottom of this. Refer to the discussion in the serialization documentation under </p> <p> Reference/serializable concept/class serialization traits/export key. </p> <p> 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. </p> <p> 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. </p> <p> 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. </p> <p> I think this will resolve the questions you've posed here. </p> <p> Thanks for your patience. </p> <p> Robert Ramey </p> Ticket Runar Undheim <r.undheim@…> Tue, 06 Apr 2010 07:17:58 GMT <link>https://svn.boost.org/trac10/ticket/3747#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3747#comment:16</guid> <description> <p> Thanks! </p> <p> Boost 1.42 and use of BOOST_CLASS_EXPORT_IMPLEMENT and BOOST_CLASS_EXPORT_KEY solved the problem. </p> <p> Runar Undheim </p> </description> <category>Ticket</category> </item> </channel> </rss>