Dear all,
We use (too many) singletons in our program and now the program crashes in
Boost Serialization because in an onexit function a static member
(oserializer::instantiate) of Boost Serialization is already destroyed.
Is there a way to force an intialisation of these static members so that they
are destroyed after my singleton destroys?
The code can be reproduced by the follwing snippet:
//
#define BOOST_ALL_DYN_LINK
#define BOOST_LIB_DIAGNOSTIC
#include <fstream>
#include
#include
#include
#include
struct Foo
{
Foo() : m_i(0)
{}
template <class Archive>
void serialize(Archive& ar, const unsigned int /*version*/)
{
ar & BOOST_SERIALIZATION_NVP(m_i);
}
int m_i;
};
void f ();
void test_serialize ();
//----------------------------------------------------------------------------
// Function main
//----------------------------------------------------------------------------
// Description : main
//----------------------------------------------------------------------------
int main()
{
atexit(&f);
test_serialize();
return 0;
}
void f()
{
test_serialize();
}
void test_serialize()
{
std::ofstream ofs("test.xml");
boost::archive::xml_oarchive oa(ofs);
const Foo foo;
oa << BOOST_SERIALIZATION_NVP(foo);
}
wkr,
me