Re: [Boost-users] [serialization] Export question
I think I just answered my own question regarding whether I can use the EXPORT macro in the header that declares the class being exported. Since the EXPORT macro instantiates a static guid_initializer for the class, including it in multiple source files creates multiple static objects and results in link errors. So at this point, I wonder, why bother with the EXPORT macro at all? Given that the class has to be registered with the archive, why not just use register_type when the archive is created? When I thought the EXPORT macro allowed me to register the class in the same header where the class is created, it seemed very useful. Now I guess I don't see any advantage of using EXPORT. Am I missing something? Thomas Aylesworth Senior Software Engineer Reality Mobile
Tom Aylesworth wrote:
I think I just answered my own question regarding whether I can use the EXPORT macro in the header that declares the class being exported. Since the EXPORT macro instantiates a static guid_initializer for the class, including it in multiple source files creates multiple static objects and results in link errors.
So at this point, I wonder, why bother with the EXPORT macro at all? Given that the class has to be registered with the archive, why not just use register_type when the archive is created? When I thought the EXPORT macro allowed me to register the class in the same header where the class is created, it seemed very useful. Now I guess I don’t see any advantage of using EXPORT. Am I missing something?
yeah. base* base = make_derived(); some_archive << base; function make_derived is loaded from a shared library that we don't have headers for. -t
On Wed, Apr 8, 2009 at 8:12 AM, Tom Aylesworth
So at this point, I wonder, why bother with the EXPORT macro at all? Given that the class has to be registered with the archive, why not just use register_type when the archive is created?
The convenience of BOOST_CLASS_EXPORT is that it is automatic, the primary use case is to just include a module in your project and voila, it auto-registers all its classes for serialization. However, BOOST_CLASS_EXPORT is not portable, in this primary use case the compiler is allowed to deadstrip it, though it contains some trickery to prevent this from happening. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
participants (3)
-
Emil Dotchevski
-
Tom Aylesworth
-
troy d. straszheim