Problem with including boost/serialization/shared_ptr.hpp

I'm attempting to apply the boost::serialization library to my application. Because it is fairly large, I've choosing to implement the serialize methods as non-templates. Such a tactic is used in some of the examples, for instance demo_polymorphic_A.hpp. This means that I don't include any boost.serialization or boost.archive headers in my definition files. A forward reference to the specific archive object is made instead. I've run into trouble with an object wrapped in a shared_pointer. To solve this, I've attempted to defined the BOOST_SHARED_POINTER_EXPORT() macro in this object's definition file. This necessitates including boost/serialization/shared_ptr.hpp. The problem is no matter what position I place this include file in this *.h file, I get the following error. boost/serialization/shared_ptr.hpp:26:2: #error "include <boost/serialization/shared_ptr> first This is a self reference, what is it trying to say? In other words, what do I have to include before boost/serialization/shared_ptr.hpp to make it happy?

Jeffrey Holle wrote:
The problem is no matter what position I place this include file in this *.h file, I get the following error. boost/serialization/shared_ptr.hpp:26:2: #error "include <boost/serialization/shared_ptr> first
This is a self reference, what is it trying to say?
In other words, what do I have to include before boost/serialization/shared_ptr.hpp to make it happy?
Looking at the source code, you have to include boost/serialization/shared_ptr.hpp before boost/shared_ptr.hpp. In case you're curious, there's been a recent thread about the implementation of this on the boost development list with the subject 'shared_ptr and serialization'. Hope that helps. Daniel

"Daniel James" wrote:
boost/serialization/shared_ptr.hpp:26:2: #error "include <boost/serialization/shared_ptr> first
Looking at the source code, you have to include boost/serialization/shared_ptr.hpp before boost/shared_ptr.hpp.
In case you're curious, there's been a recent thread about the implementation of this on the boost development list with the subject 'shared_ptr and serialization'.
The same problem yesterday ;-) The discussion is: http://lists.boost.org/MailArchives/boost/msg02559.php and the macro HACK_SERIALIZATION_EXPORT_SHARED_POINTER works. BOOST_SHARED_POINTER_EXPORT should cover functionality of HACK_SERIALIZATION_EXPORT_SHARED_POINTER. /Pavel

To really solve this problem, do the following: In your private copy of boost/serialization/shared_ptr.hpp replace #ifdef BOOST_SHARED_PTR_HPP_INCLUDED #error "include <boost/serialization/shared_ptr> first" #endif #define private public #include <boost/shared_ptr.hpp> #undef private with just: #include <boost/shared_ptr.hpp> Now when you compile, you'll get a couple of error like ... is not accessible. In your private copy of boost/shared_ptr.hpp move the problem variables out of the private section to the public section. Sorry. this is the only current option. Robert Ramey change "Jeffrey Holle" <jeff.holle@verizon.net> wrote in message news:cod5pm$tgm$1@sea.gmane.org...
I'm attempting to apply the boost::serialization library to my application.
Because it is fairly large, I've choosing to implement the serialize methods as non-templates. Such a tactic is used in some of the examples, for instance demo_polymorphic_A.hpp. This means that I don't include any boost.serialization or boost.archive headers in my definition files. A forward reference to the specific archive object is made instead.
I've run into trouble with an object wrapped in a shared_pointer. To solve this, I've attempted to defined the BOOST_SHARED_POINTER_EXPORT() macro in this object's definition file. This necessitates including boost/serialization/shared_ptr.hpp.
The problem is no matter what position I place this include file in this *.h file, I get the following error. boost/serialization/shared_ptr.hpp:26:2: #error "include <boost/serialization/shared_ptr> first
This is a self reference, what is it trying to say?
In other words, what do I have to include before boost/serialization/shared_ptr.hpp to make it happy?
participants (4)
-
Daniel James
-
Jeffrey Holle
-
Pavel Vozenilek
-
Robert Ramey