$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Ng Pan (panng_wts_at_[hidden])
Date: 2007-05-09 02:40:26
Hi
To use boost serialization on vc7.0 , rtti is better to be disabled.
One example can be found at 
boost\boost_1_33_1\libs\serialization\vc6ide\test_no_rtti
There are three classes in the example (test_no_rtti)
Orgininal code:
     class polymorphic_base
     {...}
     class polymorphic_d1 : public polymorphic_base
     {...}
     class polymorphic_d2 : public polymorphic_base
     {...}
I modified the code as following:
     class polymorphic_base
     {...}
     class polymorphic_d1 : public polymorphic_base
     {...}
     class polymorphic_d2 : public polymorphic_base
     {
           ....
           void serialize(Archive &ar, const unsigned int  /* file_version 
*/)
           {
               ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(polymorphic_base);
               ar & boost::serialization::make_nvp("Pointer_Int",m_pnInt);
               ar & boost::serialization::make_nvp("Pointer_D1",m_pD1);
            }
           ....
           public:
           polymorphic_derived1 * m_pD1;
           int * m_pnInt;
     }
The problem is occurred when compile the modifed code. I found that the code
"ar & boost::serialization::make_nvp("Pointer_Int",m_pnInt);" leads the 
compile error
" \boost\boost_1_33_1\boost\serialization\access.hpp(109): error C2228: left 
of '.serialize' must have class/struct/union type"
If I modified the code from
"ar & boost::serialization::make_nvp("Pointer_Int",m_pnInt);"
to
"ar & boost::serialization::make_nvp("Pointer_Int",*m_pnInt);"
It will become ok, but, it leads to another problem when the pointer of 
m_pnInt is NULL.
The above problem doesn't exist for another pointer m_pD1.
Both of them are pointer. The difference is that m_pnInt is integer (basic 
object) and m_pD1 is user-defined class.
I wonder what should I do to solve the mentioned problem (serialization of 
pointer of basic object).
Best regards
Barr Ng
_________________________________________________________________
Catch suspicious messages before you open themwith Windows Live Hotmail. 
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_protection_0507