[Serialization] Compile error in heap_allocator.invoke in MSVC8 debug mode
Hi, I have successfully compiled the boost libs for the serialization library using bjam and I am now trying to make use of it in my project. I am building my project in MSVC8. It has successfully compiled and run in Release mode, but I am getting a compiler error in Debug mode on the same code and am at a loss as to what the problem is. The compiler error I am getting is: iserializer.hpp(252) : error C2065: '()' : undeclared identifier Here's a bit from the template stack trace: ...iserializer.hpp(252) : error C2544: expected ')' for operator '()' ...iserializer.hpp(251) : while compiling class template member function 'World::CWorld *boost::archive::detail::heap_allocator<T>::invoke(void)' 1> with 1> [ 1> T=World::CWorld 1> ] The following is the class this is complaining about: namespace World { class CWorld { friend class boost::serialization::access; template<class Archive> void save(Archive & ar, const unsigned int version) const; template<class Archive> void load(Archive & ar, const unsigned int version); BOOST_SERIALIZATION_SPLIT_MEMBER() public: ~CWorld(); static CWorld* getWorld(){ return m_world; } static bool loadWorld(std::string filename); static bool saveWorld(std::string filename); static bool unloadWorld(); protected: CWorld(); static CWorld *m_world; }; } And the source of the error traces back to the following member function: bool CWorld::loadWorld(std::string filename) { if(m_world) return false; m_world = new CWorld(); // create and open an archive for input std::ifstream ifs(filename.c_str(), std::ios::binary); boost::archive::text_iarchive ia(ifs); // read class state from archive ia & *m_world; //!!!this is the line that the error traces to return true; } Like I said - this code compiles fine under Release mode, but this error keeps showing up on Debug mode. Any ideas on what might be wrong? And if you need more information, just ask. Thanks, Tim Murray
The attached code compiles without problem on VC 7.1 - So I can't see
any problem.
Robert Ramey
PS. rather than using somethng like
static CWorld *m_w = new CWorld;
...
ar & *m_w
You might try
static CWorld *m_w;
ar & m_w; // let serialization create the pointer
RR
begin 666 test.cpp
M(VEN8VQU9&4@/&9S=')E86T^#0HC:6YC;'5D92 \8F]O
Hmm. Thanks for your response - perhaps it is a VC 8 issue or I have an incompatible setting in the solution for debug mode. I'll keep fooling around with it. -Tim Murray Robert Ramey wrote:
The attached code compiles without problem on VC 7.1 - So I can't see any problem.
Robert Ramey
PS. rather than using somethng like
static CWorld *m_w = new CWorld;
....
ar & *m_w
You might try
static CWorld *m_w;
ar & m_w; // let serialization create the pointer
RR
begin 666 test.cpp M(VEN8VQU9&4@/&9S=')E86T^#0HC:6YC;'5D92 \8F]O
F%T M:6]N+W-P;&ET7VUE;6)E PT* M(" @(&-L87-S($-7;W)L9 T*(" @('L-"B @("!F R!R971U PT*(" @(" @("!I9BAM7W=O M _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Aha, I found the problem. Apparently in one of the other libraries I was using, new was being redefined and somehow that redefinition made its way into the serialize code which was causing it to blow up. Robert Ramey wrote:
The attached code compiles without problem on VC 7.1 - So I can't see any problem.
Robert Ramey
PS. rather than using somethng like
static CWorld *m_w = new CWorld;
....
ar & *m_w
You might try
static CWorld *m_w;
ar & m_w; // let serialization create the pointer
RR
begin 666 test.cpp M(VEN8VQU9&4@/&9S=')E86T^#0HC:6YC;'5D92 \8F]O
F%T M:6]N+W-P;&ET7VUE;6)E PT* M(" @(&-L87-S($-7;W)L9 T*(" @('L-"B @("!F R!R971U PT*(" @(" @("!I9BAM7W=O M _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Robert Ramey
-
Tim Murray