((( All -- please ignore my previous post; I have resolved the problem
and didn't intend to send that message )))
Hi Jeshua,
Vaguely related comment on your problem. I was also recently seeing this
"unregistered void cast" runtime error. As far as I could tell it was a
problem relating to my ordering and placement of "#include
I already sent a message on this topic a few weeks ago, however, my problem has a changed a bit so I decided to post a new message.
I've been trying to get Boost serialization working for dynamically loaded shared libraries. Here's my basic structure simplified:
1. base.hpp - includes an abstract base class called base 2. derived.hpp - includes a derived class from base. includes base.hpp. 3. derived.cpp - includes code for derived class and for dynamically loading it 4. main.cpp - includes base.hpp but NOT derived.hpp. dynamically loads instantiates a base * which points to a derived object from derived.so
Now in main I want to be able to serialize my pointer to the loaded derived class:
base *obj = create_func(); //obj now points to a derived object obj->test(); //when test is run it correctly outputs the message from derived.cpp
const base* const to_serialize = obj; std::ofstream ofs("filename"); boost::archive::text_oarchive oa(ofs); try { oa << (to_serialize); } catch(exception &e) { cout << "Exception: " << e.what() << "\n"; }
It compiles fine and I got past the "unregisterd class" problem, but now when I try to serialize the pointer an exception is caught: "Unregistered void cast"
This appears to be a problem with registering the derived pointer type from the base type when dynamically loaded from a shared library.
However, I do register the derived-base relationship as suggested in the documentation. The serialize method in derived.hpp is as follows:
template<class Archive> void serialize(Archive & ar, const unsigned int version) {
ar.template register_type(static_cast
(NULL)); //ar & boost::serialization::base_object<base>(*this); ar & data; boost::serialization::void_cast_register( static_cast (NULL), static_cast (NULL) ); } If anyone knows the cause of this and/or a solution I would be very appreciative. I've been working at this for a long time now and I'm almost ready to write my own simple serialization for my specific purpose.
Thank you for your help, Jeshua Bratman