
I'm not sure which version of boost you're using. 1.33.0 did have restriction regarding header order which has been removed except for a couple of special cases. The following code compiles without error with 1.33.1 #include <boost/serialization/version.hpp> #include <boost/serialization/export.hpp> namespace boost { namespace serialization { class access; } } class A { }; BOOST_CLASS_VERSION(A, 1) BOOST_CLASS_EXPORT(A) Implementation of BOOST_CLASS_EXPORT is such that this must follow any boost/archive/... headers. So in your application program I would expect to see the following: #include <boost/archive/polymorphic_archive.hpp> // and/or anyother archives #include "A.h" // any other imported classes ... ar & a ... And I would expect everything to work as expected. If A.h is included on other code which does not invoke serialization, compile time should be unaffected by inclusion of the serialization macros. Robert Ramey Mikhail Kubzin wrote:
It looks like I misunderstood the error message or/and didn't read the documentation carefully.
When I include #include <boost/serialization/version.hpp> line in my A.h file I get a compilation error message saying that it is impossible to include version.hpp before archive headers:
c:\Program Files\boost\boost\archive\basic_archive.hpp(21): fatal error C1189: #error : "no serialization headers my precede any archive headers"
That's why I have to include <boost/archive/....> headers. Since class A is used in a lot of places I get unacceptable compilation time.
Could you please advise me how to insert class version information into A.h file without including huge archive headers?
Thanks, Mikhail