[serialization][1.35.0] incompatible change in guid_initalizer?

Hi, using the serialization library in various versions, I encounter a problem with exporting guids when changing from boost 1.34.1 to 1.35.0 I am currently using gcc 4.3.0 (recent stable release) under openSuSE 10.2. I am separating the exporting macros into a header xxx_export.h. This is done to avoid excessive compilation times for files in which the export code is not needed. Moreover, various classes which have export code are separated into several files. Thus, I need to #include more than one xxx_export.h header into the final program cpp file. I get the follwing error during compile: header2_export.h:9: error: conflicting declaration ‘const boost::archive::detail::guid_initializer<Derived2>& <unnamed>::boost_serialization_guid_initializer_9’ header1_export.h:9: error: ‘<unnamed>::boost_serialization_guid_initializer_9’ has a previous declaration as ‘const boost::archive::detail::guid_initializer<Derived1>& <unnamed>::boost_serialization_guid_initializer_9’ Obviously, the symbol names are derived from the line number in the header file, right? Using two (or more) different export header files, this leads to confusion. I tried to remedy the situation by enclosing the BOOST_CLASS_EXPORT_GUID () macros in the two export header files in two different namespaces. OK, that worked. HOWEVER - it is not backward compatible with boost version 1.34.1. If I use the code that works with 1.3.50 with the earlier version, I get: In file included from exportTestn.cpp:10: header1n_export.h:10: error: expected initializer before ‘<’ token header1n_export.h:10: error: ISO C++ forbids declaration of ‘type name’ with no type header1n_export.h:10: error: wrong number of template arguments (1, should be 2) /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/stl_pair.h:72: error: provided for ‘template<class _T1, class _T2> struct std::pair’ header1n_export.h:10: error: explicit instantiation of non-template ‘int derived1::boost::archive::detail::export_archives_invoke’ header1n_export.h:10: error: expected `;' before ‘<’ token In file included from exportTestn.cpp:12: header2n_export.h:10: error: expected initializer before ‘<’ token header2n_export.h:10: error: ISO C++ forbids declaration of ‘type name’ with no type header2n_export.h:10: error: wrong number of template arguments (1, should be 2) /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/stl_pair.h:72: error: provided for ‘template<class _T1, class _T2> struct std::pair’ header2n_export.h:10: error: explicit instantiation of non-template ‘int derived2::boost::archive::detail::export_archives_invoke’ header2n_export.h:10: error: expected `;' before ‘<’ token Am I doing something wrong here? Is there a solution which works for both boost::serialization versions? I have attached the relevant files for reference. Note that files header1.h, header2.h, header1_export.h and header2_export.h are without the additional namespace, while files header1n.h, header2n.h, header1n_export.h, and header2n_export.h are WITH the additional namespace. Thanks for any help. Bernd

On Wed, 26 Mar 2008 16:41:33 +0100, Bernd Speiser wrote:
I am separating the exporting macros into a header xxx_export.h.
Just FYI, the suggested method is (now) to have the export macros in cpp files. Actually, it was OK to do it for 1.34.1 as well, which I did. -- Sohail Somani http://uint32t.blogspot.com

Sohail Somani wrote:
On Wed, 26 Mar 2008 16:41:33 +0100, Bernd Speiser wrote:
I am separating the exporting macros into a header xxx_export.h.
Just FYI, the suggested method is (now) to have the export macros in cpp files. Actually, it was OK to do it for 1.34.1 as well, which I did.
I did read this in the documentation. However, when implementing our class exports in that way, we encountered runtime errors at /usr/include/boost/archive/detail/oserializer.hpp:418: ... Assertion `__null != bpos_ptr' failed. Abort We could only get rid of this by using the export header method. I must admit that I did not really understand the error ;-) and the remedy was rather by trial and error. Regards Bernd -- ======================================================================= Bernd Speiser Institut für Organische Chemie Auf der Morgenstelle 18 temporary address: Auf der Morgenstelle 15 D-72076 Tübingen Germany phone: +49-7071-2976205 (office) +49-7071-2976242 (laboratory) +49-7071-2972098 (secretary) fax: +49-7071-295518 e-mail: bernd.speiser@uni-tuebingen.de Internet: http://www.uni-tuebingen.de/speiser =======================================================================

On Wed, 26 Mar 2008 20:30:08 +0100, Bernd Speiser wrote:
Sohail Somani wrote:
On Wed, 26 Mar 2008 16:41:33 +0100, Bernd Speiser wrote:
I am separating the exporting macros into a header xxx_export.h.
Just FYI, the suggested method is (now) to have the export macros in cpp files. Actually, it was OK to do it for 1.34.1 as well, which I did.
I did read this in the documentation. However, when implementing our class exports in that way, we encountered runtime errors at /usr/include/boost/archive/detail/oserializer.hpp:418: ... Assertion `__null != bpos_ptr' failed. Abort
We could only get rid of this by using the export header method. I must admit that I did not really understand the error ;-) and the remedy was rather by trial and error.
Oh, not a good way to go about it! My guess is that that was an order-of- includes problem. For 1.34.1, you had to include all the archives you wanted first and *then* include the export header. This requirement is now theoretically removed for most compilers. -- Sohail Somani http://uint32t.blogspot.com

Sohail Somani wrote:
On Wed, 26 Mar 2008 20:30:08 +0100, Bernd Speiser wrote:
Sohail Somani wrote:
On Wed, 26 Mar 2008 16:41:33 +0100, Bernd Speiser wrote:
I am separating the exporting macros into a header xxx_export.h. Just FYI, the suggested method is (now) to have the export macros in cpp files. Actually, it was OK to do it for 1.34.1 as well, which I did.
I did read this in the documentation. However, when implementing our class exports in that way, we encountered runtime errors at /usr/include/boost/archive/detail/oserializer.hpp:418: ... Assertion `__null != bpos_ptr' failed. Abort
We could only get rid of this by using the export header method. I must admit that I did not really understand the error ;-) and the remedy was rather by trial and error.
Oh, not a good way to go about it! My guess is that that was an order-of- includes problem. For 1.34.1, you had to include all the archives you wanted first and *then* include the export header. This requirement is now theoretically removed for most compilers.
All right, I agree that this is not the optimal way ... However, sometimes things need to be done. Of course, you are correct, that this may stike back later. Coming back to the problem: I am sure that we did take into account the ordering of headers. This was clearly spelled out in the documentation, so we followed in that respect. The question is: Is there a problem with separating the export code into additional headers? And if yes, can this lead to the behavior that I find now when moving to boost 1.35.0? Bernd -- ======================================================================= Bernd Speiser Institut für Organische Chemie Auf der Morgenstelle 18 temporary address: Auf der Morgenstelle 15 D-72076 Tübingen Germany phone: +49-7071-2976205 (office) +49-7071-2976242 (laboratory) +49-7071-2972098 (secretary) fax: +49-7071-295518 e-mail: bernd.speiser@uni-tuebingen.de Internet: http://www.uni-tuebingen.de/speiser =======================================================================
participants (3)
-
Bernd Speiser
-
bernd.speiser@t-online.de
-
Sohail Somani