boost serialization and RTTI

Hi, I very much want to use boost serialization but can't enable RTTI in my compiler (vc7/vc8) because of compatibility restrictions with other code. I've seen various statements on the web that boost serialization will work without RTTI, but no concrete instructions about how to make this happen. I've tried writing a trivial app using boost::archive::binary_oarchive, but I get this compiler warning (which is as good as an error): boost\smart_cast.hpp(76) : warning C4541: 'dynamic_cast' used on polymorphic type 'boost::archive::detail::basic_oarchive' with /GR-; unpredictable behavior may result So is it the case that, while serialization doesn't require RTTI, the provided archive classes do? Am I going to have to write my own archive class? Any help appreciated. cheers, os. -- os@collective.co.uk

There is a test program which demostates that this facility fuctions: It's named "test_no_rtti" or something like that. I make the "no rtti" version as sort of an after thought. My idea was the the type identification method be an attribute of the class as other serialization attributes were. Thus one could declare everything regarding how an type is to be serialized in the *.h file and include it in all your programs and archives containing instances of the given type would be transportable. So I was concerned that a program support varying methods. That is, I envisioned the usage of "on rtti" as a class attribute rather than a program attribute. So i wrote test_no_rtti to demonstrate and test this facility. As an example, I made a special version of extended_type_info (extended_type_info_nortti) as a test. It uses the exported class name as an identifier so it requires that the class be exported by name. So my test did/does demostrate that the serialization library can be used without rtti. However. test_no_rtti - fails without RTTI enabled. This is because the test is mis-named. It should be called test_no_rtti_rtti_interoperability. In order to not use the extened_type_info_no_rtti example as a basis for your program, you would have to make sure that all your types (an all imported types) use it. The library address this by including the default "extended_type_info.hpp" if not other extended_type_info system has been specfied. This facility has been the source of some infamous header ordering issues which have since been addressed. So it has been addressed. It hasn't been documented well nor has it been tested exhaustively. If one had nothing else to do he could tweak the serialization test so it would run ALL the tests with no_rtti. But no one has need it badly enough to to this work. I don't knowwhat else to tell you. Robert Ramey
Hi,
I very much want to use boost serialization but can't enable RTTI in my compiler (vc7/vc8) because of compatibility restrictions with other code.
I've seen various statements on the web that boost serialization will work without RTTI, but no concrete instructions about how to make this happen.
I've tried writing a trivial app using boost::archive::binary_oarchive, but I get this compiler warning (which is as good as an error):
boost\smart_cast.hpp(76) : warning C4541: 'dynamic_cast' used on polymorphic type 'boost::archive::detail::basic_oarchive' with /GR-; unpredictable behavior may result
So is it the case that, while serialization doesn't require RTTI, the provided archive classes do? Am I going to have to write my own archive class?
Any help appreciated.
cheers, os.

Thanks Robert.
I may persist with trying to get this to work, but I don't honestly
believe it will work out.
I think it would be good to include in the tests folder a single
example that would trivially serialise and deserialise data that built
with RTTI turned off in the compiler. Otherwise this option isn't
being tested at all.
cheers,
os.
On 20/04/07, Robert Ramey
There is a test program which demostates that this facility fuctions:
It's named "test_no_rtti" or something like that.
I make the "no rtti" version as sort of an after thought. My idea was the the type identification method be an attribute of the class as other serialization attributes were. Thus one could declare everything regarding how an type is to be serialized in the *.h file and include it in all your programs and archives containing instances of the given type would be transportable.
So I was concerned that a program support varying methods. That is, I envisioned the usage of "on rtti" as a class attribute rather than a program attribute.
So i wrote test_no_rtti to demonstrate and test this facility. As an example, I made a special version of extended_type_info (extended_type_info_nortti) as a test. It uses the exported class name as an identifier so it requires that the class be exported by name.
So my test did/does demostrate that the serialization library can be used without rtti. However.
test_no_rtti - fails without RTTI enabled. This is because the test is mis-named. It should be called test_no_rtti_rtti_interoperability.
In order to not use the extened_type_info_no_rtti example as a basis for your program, you would have to make sure that all your types (an all imported types) use it. The library address this by including the default "extended_type_info.hpp" if not other extended_type_info system has been specfied. This facility has been the source of some infamous header ordering issues which have since been addressed.
So it has been addressed. It hasn't been documented well nor has it been tested exhaustively. If one had nothing else to do he could tweak the serialization test so it would run ALL the tests with no_rtti. But no one has need it badly enough to to this work.
I don't knowwhat else to tell you.
Robert Ramey
Hi,
I very much want to use boost serialization but can't enable RTTI in my compiler (vc7/vc8) because of compatibility restrictions with other code.
I've seen various statements on the web that boost serialization will work without RTTI, but no concrete instructions about how to make this happen.
I've tried writing a trivial app using boost::archive::binary_oarchive, but I get this compiler warning (which is as good as an error):
boost\smart_cast.hpp(76) : warning C4541: 'dynamic_cast' used on polymorphic type 'boost::archive::detail::basic_oarchive' with /GR-; unpredictable behavior may result
So is it the case that, while serialization doesn't require RTTI, the provided archive classes do? Am I going to have to write my own archive class?
Any help appreciated.
cheers, os.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- os@collective.co.uk http://www.collective.co.uk/ http://www.myspace.com/darkroomtheband
participants (2)
-
Os
-
Robert Ramey