|
Boost : |
From: Oleg Abrosimov (beholder_at_[hidden])
Date: 2005-12-15 05:43:04
Hello!
Some days ago I've faced with very strange problem with
boost::serialization
it doesn't compile, though docs says that it should.
After some research I've found that changing the order of
header files included fixes the problem.
It can be illustrated on a base of the demo.cpp program
included in distribution:
The original order:
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/list.hpp>
The modified order [doesn't compile!]:
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/list.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
It is crucial to include these files first
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
it is because of many files (may be indirectly) include
boost/serialization/type_info_implementation.hpp header
that uses BOOST_SERIALIZATION_DEFAULT_TYPE_INFO macro without
defining it, and
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
headers define this macro in some way.
to conclude: I have found it very disappointing that changing
of order of included headers changes code correctness so
dramatically. I want it to be fixed in some way.
Thanks for great and incredibly helpful library anyway,
Oleg Abrosimov.
PS: The compiler (VC7.1) output:
Compiling...
demo.cpp
D:\home\olegabr\devel\boost_1_33_1\boost\archive\detail\oserializer.hpp(131)
: error C2027: use of undefined type
'boost::serialization::extended_type_info_null<T>'
with
[
T=bus_schedule
]
D:\home\olegabr\devel\boost_1_33_1\boost\archive\detail\oserializer.hpp(131)
: see reference to class template instantiation
'boost::serialization::extended_type_info_null<T>' being
compiled
with
[
T=bus_schedule
]
D:\home\olegabr\devel\boost_1_33_1\boost\archive\detail\oserializer.hpp(128)
: while compiling class-template member function 'bool
boost::archive::detail::oserializer<Archive,T>::is_polymorphic(void)
const'
with
[
Archive=boost::archive::text_oarchive,
T=bus_schedule
]
D:\home\olegabr\devel\boost_1_33_1\boost\archive\detail\oserializer.hpp(264)
: see reference to class template instantiation
'boost::archive::detail::oserializer<Archive,T>' being
compiled
with
[
Archive=boost::archive::text_oarchive,
T=bus_schedule
]
D:\home\olegabr\devel\boost_1_33_1\boost\archive\detail\oserializer.hpp(263)
: while compiling class-template member function 'void
boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard::invoke(Archive
&,const bus_schedule &)'
with
[
Archive=boost::archive::text_oarchive,
T=bus_schedule
]
D:\home\olegabr\devel\boost_1_33_1\boost\archive\detail\oserializer.hpp(322)
: see reference to class template instantiation
'boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard'
being compiled
with
[
Archive=boost::archive::text_oarchive,
T=bus_schedule
]
D:\home\olegabr\devel\boost_1_33_1\boost\archive\detail\oserializer.hpp(310)
: while compiling class-template member function 'void
boost::archive::detail::save_non_pointer_type<Archive,T>::invoke(Archive
&,const bus_schedule &)'
with
[
Archive=boost::archive::text_oarchive,
T=bus_schedule
]
D:\home\olegabr\devel\boost_1_33_1\boost\archive\detail\oserializer.hpp(536)
: see reference to class template instantiation
'boost::archive::detail::save_non_pointer_type<Archive,T>'
being compiled
with
[
Archive=boost::archive::text_oarchive,
T=bus_schedule
]
D:\home\olegabr\devel\boost_1_33_1\boost\archive\basic_text_oarchive.hpp(78)
: see reference to function template instantiation 'void
boost::archive::save<Archive,T>(Archive &,T &)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=const bus_schedule
]
D:\home\olegabr\devel\boost_1_33_1\boost\archive\detail\interface_oarchive.hpp(78)
: see reference to function template instantiation 'void
boost::archive::basic_text_oarchive<Archive>::save_override<T>(T
&,int)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=const bus_schedule
]
demo.cpp(286) : see reference to function template
instantiation 'Archive
&boost::archive::detail::interface_oarchive<Archive>::operator
<<<const bus_schedule>(T &)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=const bus_schedule
]
D:\home\olegabr\devel\boost_1_33_1\boost\archive\detail\oserializer.hpp(131)
: error C2146: syntax error : missing ';' before identifier
'typex'
D:\home\olegabr\devel\boost_1_33_1\boost\archive\detail\oserializer.hpp(131)
: error C2065: 'typex' : undeclared identifier
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk