Boost logo

Boost Users :

From: Lawrence Spector (Lawrence.Spector_at_[hidden])
Date: 2006-11-29 19:14:56


Hi all. I'm playing with the boost::serialization library, but having a
compile issue, with a very obscure error message. It is as follows:

 

Compiler: VC7.1 on Windows XP

 

I get the following compile errors:

 

Compiling...

TestClass.cpp

c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\detail\iserialize
r.hpp(142) : error C2027: use of undefined type
'boost::serialization::extended_type_info_null<T>'

        with

        [

            T=CppTestClass

        ]

 
c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\detail\iserialize
r.hpp(142) : see reference to class template instantiation
'boost::serialization::extended_type_info_null<T>' being compiled

        with

        [

            T=CppTestClass

        ]

 
c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\detail\iserialize
r.hpp(138) : while compiling class-template member function 'bool
boost::archive::detail::iserializer<Archive,T>::is_polymorphic(void)
const'

        with

        [

            Archive=boost::archive::text_wiarchive,

            T=CppTestClass

        ]

 
c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\detail\iserialize
r.hpp(375) : see reference to class template instantiation
'boost::archive::detail::iserializer<Archive,T>' being compiled

        with

        [

            Archive=boost::archive::text_wiarchive,

            T=CppTestClass

        ]

 
c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\detail\iserialize
r.hpp(369) : while compiling class-template member function 'void
boost::archive::detail::load_non_pointer_type<Archive,T>::load_standard:
:invoke(Archive &,T &)'

        with

        [

            Archive=boost::archive::text_wiarchive,

            T=CppTestClass

        ]

 
c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\detail\iserialize
r.hpp(425) : see reference to class template instantiation
'boost::archive::detail::load_non_pointer_type<Archive,T>::load_standard
' being compiled

        with

        [

            Archive=boost::archive::text_wiarchive,

            T=CppTestClass

        ]

 
c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\detail\iserialize
r.hpp(418) : while compiling class-template member function 'void
boost::archive::detail::load_non_pointer_type<Archive,T>::invoke(Archive
&,T &)'

        with

        [

            Archive=boost::archive::text_wiarchive,

            T=CppTestClass

        ]

 
c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\detail\iserialize
r.hpp(572) : see refe

rence to class template instantiation
'boost::archive::detail::load_non_pointer_type<Archive,T>' being
compiled

        with

        [

            Archive=boost::archive::text_wiarchive,

            T=CppTestClass

        ]

 
c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\basic_text_iarchi
ve.hpp(64) : see reference to function template instantiation 'void
boost::archive::load<Archive,T>(Archive &,T &)' being compiled

        with

        [

            Archive=boost::archive::text_wiarchive,

            T=CppTestClass

        ]

 
c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\text_wiarchive.hp
p(68) : see reference to function template instantiation 'void
boost::archive::basic_text_iarchive<Archive>::load_override<T>(T &,int)'
being compiled

        with

        [

            Archive=boost::archive::text_wiarchive,

            T=CppTestClass

        ]

 
c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\detail\interface_
iarchive.hpp(76) : see reference to function template instantiation
'void boost::archive::text_wiarchive_impl<Archive>::load_override<T>(T
&,int)' being compiled

        with

        [

            Archive=boost::archive::text_wiarchive,

            T=CppTestClass

        ]

        c:\Work\Sandbox\CppThroughCOM\CppThroughCOM\TestClass.cpp(67) :
see reference to function template instantiation 'Archive
&boost::archive::detail::interface_iarchive<Archive>::operator
>><CppTestClass>(T &)' being compiled

        with

        [

            Archive=boost::archive::text_wiarchive,

            T=CppTestClass

        ]

c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\detail\iserialize
r.hpp(142) : error C2146: syntax error : missing ';' before identifier
'typex'

c:\Dev.Releasev7.2.CR4556\3rdparty\boost\boost\archive\detail\iserialize
r.hpp(142) : error C2065: 'typex' : undeclared identifier

 

 

Here's my code:

 

CppTestClass.hpp:

 

#pragma once

 

#include <boost/serialization/serialization.hpp>

#include <boost/serialization/base_object.hpp>

#include <boost/serialization/version.hpp>

 

class CppTestClass

{

private:

      int m_x;

 

public:

      CppTestClass(void);

      virtual ~CppTestClass(void);

 

private:

      friend class boost::serialization::access;

 

      template<class Archive>

      void load(Archive & ar, const unsigned int version)

      {

            ar & version;

            ar & m_x;

      }

 

      template<class Archive>

      void save(Archive & ar, const unsigned int version) const

      {

            ar & version;

            ar & m_x;

      }

 

public:

      friend std::wostream& operator<<(std::wostream& p_stream, const
CppTestClass& p_testClass)

      {

            p_stream << p_testClass.m_x;

 

            return p_stream;

      }

 

      friend std::wistream& operator>>(std::wistream& p_stream,
CppTestClass& p_testClass)

      {

            p_stream >> p_testClass.m_x;

 

            return p_stream;

      }

 

      BOOST_SERIALIZATION_SPLIT_MEMBER()

            

public:

      void setX(int p_x)

      {

            m_x = p_x;

      }

 

      int getX() const

      {

            return m_x;

      }

};

 

BOOST_CLASS_VERSION(CppTestClass, 1)

 

In TestClass.cpp:

 

This gives no compile errors:

 

      std::wstringstream ofs;

      boost::archive::text_woarchive oa(ofs);

 

      // write class instance to archive

      ofs << m_cppTestClass;

 

      ofs >> serData;

 

However, this does:

 

      // create and open an archive for input

      std::wstringstream ifs;

      ifs << serData;

      boost::archive::text_wiarchive ia(ifs);

      // read class state from archive

      ia >> m_cppTestClass; //!!! errant line?

 

Any ideas what's going on?

 

Thanks in advance,

 

Lawrence



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net