Opened 16 years ago

Closed 16 years ago

#803 closed Support Requests (None)

serialization and namespaces incompatability

Reported by: gorogoro Owned by: Robert Ramey
Milestone: Component: None
Version: None Severity:
Keywords: Cc:

Description

Hi!

I'm trying to use boost serialization library in my project.

I've lanched jambuild with no problems and I have the library working. But there is a stress using namespace.
My classes are all inside a namespace and when I try to use:
BOOST_CLASS_TRACKING(A, boost::serialization::track_never)

where A is:

namespace FlowEngine
{
  class A
  {
   public:
	
     template<class Archive>
     void serialize(Archive & ar, const unsigned int version)
     {			
       ar & dumbf;
       ar & dumbi;
     }
		
     int dumbi;
     float dumbf;
     
     A():dumbi(12), dumbf(69.69f){ }

     A(int dumb1, float dumb2) : dumbi(dumb1), dumbf(dumb2){ }
  };

BOOST_CLASS_TRACKING(A, boost::serialization::track_never)

main....

}

//////////////////////////////

I get this compile errors:
error C2888: 'boost::serialization::tracking_level<FlowEngine::A>' : symbol cannot be defined within namespace 'FlowEngine'

I'm using VC-80 setup.

Is there a way to turn around the problem??

Change History (5)

comment:1 by gorogoro, 16 years ago

Logged In: YES 
user_id=1684407
Originator: YES

Another thing I've notest is that if I use the & operator instead of the << and >> on the function to wrote and read the object there aren't any problem.

But if i use the << or >> 
like here:

int SilvTask::WriteObject()
{
  A aux(12356, 8956.69f);	
  //testAPointer = FE_NEW A(987, 123.56987f);
  // create and open a character archive for output
  std::ofstream ofs(m_filename.c_str());
  boost::archive::text_oarchive oa(ofs);
  //write class instance to archive
  oa << testAPointer;

  return FE_OK;
}

it gives me this error on compilation:

error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'
        with
        [
            x=false
        ]
        d:\flow project\flowengine\3rdparty\include\boost\archive\basic_text_oarchive.hpp(78) : see reference to function template instantiation 'void boost::archive::save<Archive,T>(Archive &,T &)' being compiled
        with
        [
            Archive=boost::archive::text_oarchive,
            T=FlowEngine::A *
        ]
        d:\flow project\flowengine\3rdparty\include\boost\archive\detail\interface_oarchive.hpp(78) : see reference to function template instantiation 'void boost::archive::basic_text_oarchive<Archive>::save_override<T>(T &,int)' being compiled
        with
        [
            Archive=boost::archive::text_oarchive,
            T=FlowEngine::A *
        ]
        d:\flow project\flowengine\samples\silvestre\main2.cpp(141) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<FlowEngine::A*>(T &)' being compiled
        with
        [
            Archive=boost::archive::text_oarchive,
            T=FlowEngine::A *
        ]

That's why I'm trying to use the BOOST_CLASS_TRACKING(FlowEngine::A, boost::serialization::track_always);


comment:2 by Robert Ramey, 16 years ago

Logged In: YES 
user_id=396141
Originator: NO

Try using BOOST_CLASS_TRACKING(FlowEngine::A, boost::serialization::track_never) outside of the namespace

Check the "rationale" section of the documentation for issues related to interaction of "const" and "tracking.

Robert Ramey

comment:3 by Robert Ramey, 16 years ago

Logged In: YES 
user_id=396141
Originator: NO

BOOST_CLASS_TRACKING should be specified out side any namespace

comment:4 by Robert Ramey, 16 years ago

Logged In: YES 
user_id=396141
Originator: NO

Thank you for submitting a Boost tech support request. <BR>*** 
At this time, tech support requests to this SourceForge tracker 
are monitored at best sporadically. A more reliable way to get 
answers is to post to the boost mailing list at <a 
href="http://groups.yahoo.com/group/boost">http://groups.yahoo.co
m/group/boost</a>. Although the maintainers of Boost libraries 
try to respond to questions in a timely fashion, we offer no 
guarantee of service, express or implied. ***

comment:5 by Robert Ramey, 16 years ago

Status: assignedclosed
Note: See TracTickets for help on using tickets.