
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 "Robert Ramey" <ramey@rrsd.com> wrote in message news:dn9mli$ljh$1@sea.gmane.org...
Hmmm - my question is:
My intention has always been that serialization "features" for class A always be defined in A.h. That way the correct and consistent set of "features" would be used by all programs which use class A. So I would expect A.h to look like:
#include <boost/serialization/version.hpp>
namespace boost { namespace serialization { class access; } } class A {... }; BOOST_CLASS_VERSION(A, 1)
which I think would solve your problem.
I would not expect this to slow down compilation significantly unless as long as no <boost/archive/....> headers are not included.
Robert Ramey
Mikhail Kubzin wrote:
I use boost serialisation in my project and I need to serialise a vector of pointers (boost::shared_ptr) to a base class. The base class is declared in one dll in the following way:
A.h:
namespace boost { namespace serialization { class access; } } class A {... };
A.cpp #include <... boost serialization headers .. > BOOST_CLASS_VERSION(A, 1)
....
In another dll I declare class B derived from A declared and implemented in the same manner ( .h files do not include boost serialization headers). The problem is that inside the sirialisation (save/load) function of the derived class I get correct file_version value while in the serialisation function of the base class file_version is 0.
I call serialization function of the base class as advised in the documentation: ar & boost::serialization::base_object<A>(*this);
However, if I insert BOOST_CLASS_VERSION(A, 1) into B.cpp then file_version in A's serialisation function is initialised properly.
It is a pain to update the version of the base class in all derived classes from one side, it is also impractical to include all boost headers and class version information into .h files since the compilation time grows dramatically and the size of the executables increases several times.
Any thoughts and suggestions are welcome! Thank you in advance,
Mikhail
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost