|
Boost : |
From: Zajo (emildotchevski_at_[hidden])
Date: 2007-03-21 12:45:16
> Of course alternative solution, as Emil suggests, is not to change
> boost::serialization, but to register the classes manually (with
> manually chosen identifier string). But then we at least need a
> BIG FAT warning in the documentation regarding the use of
> BOOST_CLASS_EXPORT, and a possible pitfall: code refactoring loses
> archive compatibility.
There is another warning which is missing from the documentation: portable
code can not rely on BOOST_CLASS_EXPORT to register a class unless the user
explicitly calls a function from a compilation unit that "sees" that
particular BOOST_CLASS_EXPORT call. This is because it relies on a global
object's constructor to initiate the registration process, but a good
compiler will deadstrip all such global objects unless the user explicitly
calls a function from the compilation unit that defines them.
In other words BOOST_CLASS_EXPORT isn't automatic because a portable program
is required to (manually) call a (possibly empty) function from the
registered class' cpp file. This is contradictory to BOOST_CLASS_EXPORT's
intended use to register derived classes automatically, just by linking
their cpp files.
Emil Dotchevski
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk