[Serialization] Problems Getting Started

It seems that most people are getting past this, but I have been unable to
get serialization to get to work on even simple classes. A search of the
last three months' archives and google didn't turn up anything obvious, so I
am relying on your good humor.
When I try to compile a (I think simple) class like
#include <fstream>
#include

Jeff,
Try #include
It seems that most people are getting past this, but I have been unable to get serialization to get to work on even simple classes. A search of the last three months' archives and google didn't turn up anything obvious, so I am relying on your good humor.
When I try to compile a (I think simple) class like
#include <fstream> #include
#include #include class Card { public: Card():name("Icky"){} private: std::string name;
friend class boost::serialization::access; template <class Archive> void serialize(Archive &ar, const unsigned int version) { ar & name; } };
int main(int argc, char *argv[]) { const Card Howdy;
std::ofstream ofs("Foo"); boost::archive::text_oarchive oa(ofs);
oa << Howdy; }
I get myriad errors
mcbeth@sirocco ~/tmp/blah $ g++ blah.cpp -lboost_serialization /usr/include/boost/archive/detail/oserializer.hpp: In constructor 'boost::archive::detail::oserializer
::oserializer() [with Archive = boost::archive::text_oarchive, T = Card]': /usr/include/boost/archive/detail/oserializer.hpp:135: instantiated from 'static boost::archive::detail::oserializer & boost::archive::detail::oserializer ::instantiate() [with Archive = boost::archive::text_oarchive, T = Card]' /usr/include/boost/archive/detail/oserializer.hpp:264: instantiated from 'static void boost::archive::detail::save_non_pointer_type ::save_standard::invoke(Archive&, const T&) [with Archive = boost::archive::text_oarchive, T = Card]' /usr/include/boost/archive/detail/oserializer.hpp:322: instantiated from 'static void boost::archive::detail::save_non_pointer_type ::invoke(Archive&, const T&) [with Archive = boost::archive::text_oarchive, T = Card]' /usr/include/boost/archive/detail/oserializer.hpp:536: instantiated from 'void boost::archive::save(Archive&, const T&) [with Archive = boost::archive::text_oarchive, T = Card]' /usr/include/boost/archive/basic_text_oarchive.hpp:78: instantiated from 'void boost::archive::basic_text_oarchive<Archive>::save_override(T&, int) [with T = const Card, Archive = boost::archive::text_oarchive]' /usr/include/boost/archive/detail/interface_oarchive.hpp:78: instantiated from 'Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T = const Card, Archive = boost::archive::text_oarchive]' blah.cpp:26: instantiated from here /usr/include/boost/archive/detail/oserializer.hpp:107: error: incomplete type 'boost::serialization::extended_type_info_null<Card>' used in nested name specifier /usr/include/boost/archive/detail/oserializer.hpp: In member function 'bool boost::archive::detail::oserializer ::is_polymorphic() const [with Archive = boost::archive::text_oarchive, T = Card]': blah.cpp:26: instantiated from here /usr/include/boost/archive/detail/oserializer.hpp:131: error: invalid use of undefined type 'struct boost::serialization::extended_type_info_null<Card>' /usr/include/boost/serialization/type_info_implementation.hpp:26: error: declaration of 'struct boost::serialization::extended_type_info_null<Card>' /usr/include/boost/archive/detail/oserializer.hpp:132: error: invalid use of undefined type 'struct boost::serialization::extended_type_info_null<Card>' /usr/include/boost/serialization/type_info_implementation.hpp:26: error: declaration of 'struct boost::serialization::extended_type_info_null<Card>' The relevant bit seems to be that extended_type_info_null<Card> is an incomplete type, which would point to me missing an important header or something. Relevant details Fails on (with slightly different wording but same errors) Gentoo Linux, g++-4.1.1, Boost 1.33.1 Gentoo Linux, g++-3.4.6, Boost 1.33.1 Max OSX (Tiger), g++-4.0.1, Boost 1.33.1 Max OSX (Tiger), g++-3.3, Boost 1.33.1
If needed, I can try it out on a WinXP box with VS2003 in about 7 hours.
Thanks again for your patience Jeff
--
:: Mikko Vainio

I see nothing wrong with your example. I compiled your code with no problems or messages of any kind on the following compilers: VC 7.1, Borland 5.51 Borland 5.64, Commeau, gcc 3.3 I am using the Boost Head branch. But that shouldn't make a difference. can you compile any of the tests or demos included with the package? Robert Ramey Jeffrey Brent McBeth wrote:
It seems that most people are getting past this, but I have been unable to get serialization to get to work on even simple classes. A search of the last three months' archives and google didn't turn up anything obvious, so I am relying on your good humor.
When I try to compile a (I think simple) class like
#include <fstream> #include
#include #include class Card { public: Card():name("Icky"){} private: std::string name;
friend class boost::serialization::access; template <class Archive> void serialize(Archive &ar, const unsigned int version) { ar & name; } };
int main(int argc, char *argv[]) { const Card Howdy;
std::ofstream ofs("Foo"); boost::archive::text_oarchive oa(ofs);
oa << Howdy; }
I get myriad errors
mcbeth@sirocco ~/tmp/blah $ g++ blah.cpp -lboost_serialization /usr/include/boost/archive/detail/oserializer.hpp: In constructor 'boost::archive::detail::oserializer
::oserializer() [with Archive = boost::archive::text_oarchive, T = Card]': /usr/include/boost/archive/detail/oserializer.hpp:135: instantiated from 'static boost::archive::detail::oserializer & boost::archive::detail::oserializer ::instantiate() [with Archive = boost::archive::text_oarchive, T = Card]' /usr/include/boost/archive/detail/oserializer.hpp:264: instantiated from 'static void boost::archive::detail::save_non_pointer_type save_standard::invoke(Archive&, const T&) [with Archive = boost::archive::text_oarchive, T = Card]' /usr/include/boost/archive/detail/oserializer.hpp:322: instantiated from 'static void boost::archive::detail::save_non_pointer_type
::is_polymorphic() const [with Archive = boost::archive::text_oarchive, T = Card]': blah.cpp:26: instantiated from here /usr/include/boost/archive/detail/oserializer.hpp:131: error: invalid use of undefined type 'struct boost::serialization::extended_type_info_null<Card>' /usr/include/boost/serialization/type_info_implementation.hpp:26: error: declaration of 'struct boost::serialization::extended_type_info_null<Card>' /usr/include/boost/archive/detail/oserializer.hpp:132: error: invalid use of undefined type 'struct boost::serialization::extended_type_info_null<Card>' /usr/include/boost/serialization/type_info_implementation.hpp:26: error: declaration of 'struct boost::serialization::extended_type_info_null<Card>' The relevant bit seems to be that extended_type_info_null<Card> is an incomplete type, which would point to me missing an important header or something. Relevant details Fails on (with slightly different wording but same errors) Gentoo Linux, g++-4.1.1, Boost 1.33.1 Gentoo Linux, g++-3.4.6, Boost 1.33.1 Max OSX (Tiger), g++-4.0.1, Boost 1.33.1 Max OSX (Tiger), g++-3.3, Boost 1.33.1
If needed, I can try it out on a WinXP box with VS2003 in about 7 hours.
Thanks again for your patience Jeff

On Thu, Feb 08, 2007 at 08:11:57AM -0800, Robert Ramey wrote:
I see nothing wrong with your example.
I compiled your code with no problems or messages of any kind on the following compilers: VC 7.1, Borland 5.51 Borland 5.64, Commeau, gcc 3.3
I am using the Boost Head branch. But that shouldn't make a difference.
Wow, okay. I'm doing something seriously wrong then. I tried the same code
on my VC7.1 today and got the same error about incomplete types as on my Mac
and Linux boxen. I have one more Linux box with a compiler I can try it on
(it is a different distribution)
demo.cpp compiles and appears to work fine.
And, in fact if I add a std::string to it, it continues to work fine.
Hmmm... Ahhh, I haven't seen that in a while.
If I switch the archive includes with the serialization includes, it compiles.
So,
#include

The documentation of 1.33 does describe issues related to header ordering. Header order restrictions have been eliminated in 1.34. Robert Ramey Jeffrey Brent McBeth wrote: On Thu, Feb 08, 2007 at 08:11:57AM -0800, Robert Ramey wrote:
I see nothing wrong with your example.
I compiled your code with no problems or messages of any kind on the following compilers: VC 7.1, Borland 5.51 Borland 5.64, Commeau, gcc 3.3
I am using the Boost Head branch. But that shouldn't make a difference.
Wow, okay. I'm doing something seriously wrong then. I tried the same code
on my VC7.1 today and got the same error about incomplete types as on my Mac
and Linux boxen. I have one more Linux box with a compiler I can try it on
(it is a different distribution)
demo.cpp compiles and appears to work fine.
And, in fact if I add a std::string to it, it continues to work fine.
Hmmm... Ahhh, I haven't seen that in a while.
If I switch the archive includes with the serialization includes, it
compiles.
So,
#include

On Thu, Feb 08, 2007 at 06:52:50PM -0800, Robert Ramey wrote:
The documentation of 1.33 does describe issues related to header ordering.
Header order restrictions have been eliminated in 1.34.
Robert Ramey
Thank you again for your incredible patience and courtesy (and if I'm not mistaken, library). Jeff -- ---------------------------------------------------------------------------- Computer Science is as much about computers as astronomy is about telescopes -- Edsger Wybe Dijkstra (1930-2002) ----------------------------------------------------------------------------
participants (3)
-
Jeffrey Brent McBeth
-
Mikko Vainio
-
Robert Ramey