|
Boost : |
From: Bernd Speiser (bernd.speiser_at_[hidden])
Date: 2008-03-26 11:41:33
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk