Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2007-04-28 00:47:25


Sohail Somani wrote:
>> -----Original Message-----
>> From: boost-users-bounces_at_[hidden]
>> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Robert
>> Ramey Sent: Thursday, April 26, 2007 9:06 PM
>> To: boost-users_at_[hidden]
>> Subject: Re: [Boost-users] [Serialization] Multiple
>> BOOST_CLASS_EXPORT
>>
>> This has caused problems in the past. I believe that the code
>> checked into the current HEAD branch of the CVS tree
>> addresses this, but I havn't been able to test it.
>>
>> My intention was the BOOST_CLASS_EXPORT would
>> be included in the *.h file for the class.
>
> If you have BOOST_CLASS_EXPORT in a header file, doesn't that cause
> the same problems? If this is what your checkins would fix, then
> that's understandable.

No - code is only instatiated for archives actually used. So if the usage
of an archive is confined to ONE module there are no problems. But
this requires instatiating the serialization functions not in the header -
that
is in "out of line" code. Its quite doable but somewhat annoying. This
is a result of the C++ instantiation model. Note that different compilers
and linkers do things differently, but I believe that this method works
on all of them.

Downside you have to explictly instantiate combination of type/archive
you might export. So I recommend putting them in a library and
linking against that so you don't suffer from code bloat.

Finally, you can also use the polymorphic version of the archive.
This permits you to compile only one instantiation for all archive types.
Linking
is accomplished at runtime via a virtual function interface.

> I am starting to lean towards centralizing all the serialization logic
> rather than having it local to the relevant classes as you suggest. I
> prefer locality for obvious reasons. But maybe such a cross-cutting
> concern should be in a single place. Any thoughts (from serialization
> users even?)

It saves a lot of compilation time.

>
> Thanks,
>
> Sohail


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