Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-01-22 04:01:15


Vladimir Prus wrote:

> IOW, it's required that archives to be used with exported classes
> are included before you do BOOST_EXPORT? Indeed, when I add
>
> #include <boost/archive/text_oarchive.hpp>
>
> everything starts to work. I guess I've no problem with this solution --
> since I don't know how else EXPORT would work.
>
> But it's unfortunate to get assert like above -- newbie will immediately
> decide it's a bug in serialization library. OTOH, requiring that all
> archive headers are included before BOOST_CLASS_EXPORT is probably
> overkill.

I've got more problems with this. I've tried to use xml_oarchive, and forgot
to include proper header before BOOST_CLASS_EXPORT. The program is attached,
and it crashes at runtime with segfault.

Here's what debugger shows:
Program received signal SIGSEGV, Segmentation fault.
0x4011d407 in std::ostream::sentry::sentry(std::ostream&) ()
   from /usr/lib/libstdc++.so.5
(gdb) where
#0 0x4011d407 in std::ostream::sentry::sentry(std::ostream&) ()
   from /usr/lib/libstdc++.so.5
#1 0x4011cdd6 in std::ostream::put(char) ()
   from /usr/lib/libstdc++.so.5
#2 0x0804cff7 in
boost::archive::basic_text_oprimitive<boost::archive::text_oarchive,
std::ostream>::put(int) (this=0xbffff63c, c=10)
    at basic_text_oprimitive.hpp:97

Heh, I'm using xml_oarchive, not text_oarchive, so seems like some code is
confused and uses text_oarchive when it should not.

Later on, I've added missing #include (commented out in derived.cpp in the
code I send). The results are not good, either. See attached error messages.

It seems that xml_oarchive expects NVP somewhere, but BOOST_CLASS_EXPORT fails
to provide it.

Finally, when I change 'derived.cpp' to start with:

    #include <boost/archive/text_oarchive.hpp>
    #include <boost/archive/binary_oarchive.hpp>
    #include <boost/serialization/export.hpp>

Add

  #include <boost/archive/binary_oarchive.hpp>

to main.cpp before

  #include <boost/archive/text_oarchive.hpp>

and use binary_oarchive for storing, I get:

main: /space/NM/boost-serialization/boost/archive/basic_text_oarchive.hpp:128:
void boost::archive::basic_text_oarchive<Archive>::newtoken() [with Archive =
boost::archive::text_oarchive]: Assertion `false' failed.
Aborted

Again, look like text archive is used... not binary one as should be.

- Volodya
   







Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk