Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-01-07 15:06:33


I see how this would work. I would hope my method in the previous post would
work as well.

Robert Ramey

Bill Lear wrote:
> On Friday, January 7, 2005 at 10:58:13 (-0800) Robert Ramey writes:
>> ...
>> The whole concept behind BOOST_CLASS_EXPORT has been problematic for
>> me for a couple of reasons. As a result, the confusion you cite is
>> a real one.
>
> I settled on the following that a friend suggested, which seems to
> work.
>
> In my serialization/util.h file, I have the following:
>
> template <class T>
> void save(const T* t, const std::string& filename) { ... }
>
> template <class T>
> T* load(const std::string& filename) { ... }
>
> at the bottom of this file, I have the following:
>
> namespace dummy { struct bogus { static int bogus_method(); }; }
>
> // force linking with util.cc
> static int bogus_variable = dummy::bogus::bogus_method();
>
> in serialization/util.cc, I have:
>
> #include <serialization/util.h>
>
> // expensive include which we wish to relegate to one one source
> file. #include <AllDerived.h>
>
> // the trigger method that forces others to link with this module
> int dummy::bogus::bogus_method() { return 0;}
>
> The AllDerived.h file has includes for all my headers and all the
> BOOST_CLASS_EXPORT macros.
>
> In my application code, I do this:
>
> #include <Base.h>
> #include <serialization/util.h>
>
> and it all works flawlessly. I am spared from including the headers
> for my derived classes, and the accompanying export macros. The save
> and load routines work as expected.
>
>
> Bill


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