I am using Boost 1.33.0 with MinGW 3.4.2. I plan to use the Boost serialization library in a project I am working on. Following the tutorial (but allowing for XML archives rather than text) I have successfully included code like the following in my classes: #include <fstream> #include "boost/archive/xml_oarchive.hpp" #include "boost/archive/xml_iarchive.hpp" class ClassWhatever { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive& ar, const unsigned int version) { ar & mResults; ar & mInputs; ar & mDisplayObject; }//serialize() . . . }; This code compiles without error in all classes. Now, I'm writing unit tests for the classes and I want to trigger the save and later reload of these classes. Following the same serialization tutorial, I tried this: . . . { ofstream outStream(archiveFile); boost::archive::xml_oarchive outArchive(outStream); outArchive << testObj_out; } // archive and stream closed when destructors are called . . . and similar code for the later load from the archive. When I compile this, I get massive errors, a few of which are shown below. (I've manually wrapped the long lines in an attempt to make it more readable--but I may have just made it worse.) I'm sort of guessing that there is a header or two missing. Any suggestions? Also, there are "polymorphic_..." versions of the archive files available, but I don't remember seeing them mentioned in the documentation. I have polymorphic classes. Should I be using the polymorphic versions of the headers? Merrill ======================================== E:/Dev-Cpp/Workflow/boost/include/boost/archive/basic_xml_oarchive.hpp: In member function `void boost::archive::basic_xml_oarchive<Archive>:: save_override(T&, int) [with T = boost::shared_ptrWkFlo::Successor, Archive = boost::archive::xml_oarchive]': E:/Dev-Cpp/Workflow/boost/include/boost/archive/detail/interface_oarchive.hpp:85: instantiated from `Archive& boost::archive::detail::interface_oarchive<Archive>:: operator<<(T&) [with T = WkFlo::Successor_ptr, Archive = boost::archive::xml_oarchive]' E:/Dev-Cpp/Workflow/test/src/Successor_Test.cc:111: instantiated from here E:/Dev-Cpp/Workflow/boost/include/boost/archive/basic_xml_oarchive.hpp:86: error: incomplete type `boost::STATIC_ASSERTION_FAILURE< false>' used in nested name specifier E:/Dev-Cpp/Workflow/boost/include/boost/archive/basic_xml_oarchive.hpp:86: error: size of array has non-integral type `<type error>' E:/Dev-Cpp/Workflow/boost/include/boost/archive/basic_xml_iarchive.hpp: In member function `void boost::archive::basic_xml_iarchive<Archive>:: load_override(T&, int) [with T = boost::shared_ptrWkFlo::Successor, Archive = boost::archive::xml_iarchive]': E:/Dev-Cpp/Workflow/boost/include/boost/archive/xml_iarchive.hpp:74: instantiated from `void boost::archive::xml_iarchive_impl<Archive>:: load_override(T&, int) [with T = boost::shared_ptrWkFlo::Successor, Archive = boost::archive::xml_iarchive]' E:/Dev-Cpp/Workflow/boost/include/boost/archive/detail/interface_iarchive.hpp:84: instantiated from `Archive& boost::archive::detail::interface_iarchive<Archive>:: operator>>(T&) [with T = WkFlo::Successor_ptr, Archive = boost::archive::xml_iarchive]' E:/Dev-Cpp/Workflow/test/src/Successor_Test.cc:121: instantiated from here . . . and so on
see comments below: Merrill Cornish wrote:
I tried this:
. . . { ofstream outStream(archiveFile); boost::archive::xml_oarchive outArchive(outStream); outArchive << testObj_out; } // archive and stream closed when destructors are called . . .
Look in the manual under Tutorial/List of Examples for pointers to special considerations regarding XML. ...
E:/Dev-Cpp/Workflow/boost/include/boost/archive/basic_xml_oarchive.hpp:86: error: incomplete type `boost::STATIC_ASSERTION_FAILURE< false>' used in nested name specifier
When you get a STATIC_ASSERTION_FAILURE look in the code where the failure occurs to find a comment on probable cause of the error. In this case you will find; // Anything not an attribute and not a name-value pair is an // error and should be trapped here. template<class T> void save_override(T & t, BOOST_PFTO int) { // If your program fails to compile here, its most likely due to // not specifying an nvp wrapper around the variable to // be serialized. BOOST_STATIC_ASSERT(0 == sizeof(T)); } Which points to the manual (nvp wrappers) indicating how to fix the problem. Robert Ramey
participants (2)
-
Merrill Cornish
-
Robert Ramey