|
Boost Users : |
From: Jim Lear (jim.lear_at_[hidden])
Date: 2005-01-07 15:28:50
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 mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Jim Lear This document/email may contain confidential, proprietary or privileged information and is intended only for use of the addressee/recipient named above. No confidentiality or privilege is waived or lost by any error in transmission of this document/email. If you are not the intended recipient of this document/email of Legerity, Inc., you are hereby notified that you must not use, disseminate, or copy it in any form or take any action in reliance on it. If you have received this document/email in error, please immediately notify me at (512) 228-5760 and permanently destroy/delete the original document/email and any copy of the document/email and printout thereof.
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