[Serialization] assertion failure on exit

I'm getting the following assertion failure on exit when instantiating certain serializable classes: Assertion failed: NULL != l, file libs\serialization\src\extended_type_info.cpp, line 47 I was finally able to determine a difference between the classes that caused the assertion failure and those that didn't. Here's some code: ////////////////////////////////////////////////////////////////// // Serializable.hpp: class Serializable { public: virtual ~Serializable() = 0; template< typename Archive > void serialize( Archive& /*ar*/, const unsigned int /*version*/ ) { } private: }; inline Serializable::~Serializable() { } BOOST_CLASS_EXPORT( Serializable ) ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// // Foo.hpp: struct Foo : Serializable { template< typename Archive > void serialize( Archive& ar, const unsigned int /*version*/ ) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Serializable ); } }; BOOST_CLASS_EXPORT( Foo ) ////////////////////////////////////////////////////////////////// The above code does not assert on exit after instantiating a Foo object. However, if I make Foo not header-only like so: ////////////////////////////////////////////////////////////////// // Foo.hpp: struct Foo : Serializable { Foo(); template< typename Archive > void serialize( Archive& ar, const unsigned int /*version*/ ) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Serializable ); } }; BOOST_CLASS_EXPORT( Foo ) ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// // Foo.cpp: Foo::Foo() { } ////////////////////////////////////////////////////////////////// then I get the assertion failure on program exit if I so much as instantiate a Foo object.

After further experimentation, it seems I only get the assertion on exit when the same class is exported via the BOOST_CLASS_EXPORT macro in multiple translation units. So I could probably fix my problem by adding a cpp for all of my simple classes and putting the export macro in there, but that's silly. I must be missing something.

Ah, well I finally happened across this link: http://www.boost.org/doc/libs/1_37_0/libs/serialization/doc/special.html#exp... which contains the blurb: "Also, when making shared libraries, there is currently a restriction that only one such library can use BOOST_CLASS_EXPORT for any given type. All this will most likely make it inconvenient to include BOOST_CLASS_EXPORT as part of the header of the class to be serialized. So, the best way to use BOOST_CLASS_EXPORT is to include it in the same module which implements the class." Are there any plans to remove this restriction somehow in the future?
participants (1)
-
Kenny Riddile