Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization][1.42.0] gcc(4.01)/xcode(3.1.2) failure to register type
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-05-04 16:32:27


Jeff Flinn wrote:
>>> Should explicit
>>> registration be done in combination with or en lieu of
>>> BOOST_CLASS_EXPORTxxx?
>>
>> That would be one way.
>
> Hmm, seems like I asked about two mutually exclusive ways. ;-)
>
>> Another way would be to create a "pseudo module" in
>> your program which explicitly refers to the serialization functions.
>> (for example by taking their address?) You're kind of on your own.
>
> Thant's what I've been thinking. It's not so bad if I can then get rid
> of the BOOST_CLASS_EXPORT_XXX macros. Also I was expecting
> archive::register_type to merely need a class forward declaration, but
> appears that it requires a complete type. Is that intended? That adds
> a lot of coupling.

The basic problem is:

application pulls from the static library only those functions explicitly
referred to.

call a function through a base class pointer does explicitly refer
to the derived class.

Of course these two ideas conflict and there can be no resolution
without violating the original motivation for these concepts in the first
place. Another way of saying this is that we want to couple our
application to some type/function which we haven't explicitly referenced.

The only way to resolve this is to explicitly reference these
types/functions.
The register_type facility does this on an archive by archive level.
EXPORT does this for the whole program so it propagates this facility
to the all archives.

So the simplest would be to use register type. It might be possible
to enhance EXPORT in some way for static libraries. The problem
is that it would start sucking in all the library code whether need
or not - thereby defeating the whole purpose of a static library
in the first place.

Maybe a nice way would be to craft something like

#include <boost/serialization/extended_type_info_typeid.hpp>

using boost::serialization;

void
register_all_modules(){
    const extended_type_info & eti =
extended_type_info_typeid<my_type>::get_const_instance const
extended_type_info & eti =
extended_type_info_typeid<my_type>::get_const_instance();


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net