
Robert Ramey:
Peter Dimov wrote:
Maybe the serialization library could provide an alternative function-based registration mechanism that would be immune to the static library problem. Or maybe it already provides it:
guid_initializer< T >().export_guid( "T" );
This is less convenient, but has the advantage of working. :-)
I believe that making a *.cpp file with the macros BOOST_CLASS_EXPORT(T) would be exactly equivalent to the above.
Well, it depends on where the .cpp file is. If it's part of the static library, it will not be included by the linker because there are no references to it. But it is true that A.cpp: void register_types() { guid_initializer<T1>().export_guid("T1"); guid_initializer<T2>().export_guid("T2"); guid_initializer<T3>().export_guid("T3"); } and B.cpp: BOOST_CLASS_EXPORT(T1) BOOST_CLASS_EXPORT(T2) BOOST_CLASS_EXPORT(T3) void register_types() { } are more or less equivalent (as part of the static library).