Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::serialization "input stream error" inrelease-build (msvc2010)
From: Robert Ramey (ramey_at_[hidden])
Date: 2012-05-22 11:51:25


Jens Saathoff wrote:
> Hi!
>
>
>
> I'm using boost::serialization to save a structure to a file and read
> from a file. My code works perfect in debug-build, but in
> release-build an exception is thrown. I'm using MSVC2010 to build the
> project on Windows 7 64-Bit-Machine. The code is the same. Who could
> help me out?
>
> You can find the code here: http://boost.codepad.org/8fp6XnC3
>

Hmmm - closing the datafile while the archive class is still open? Bad
idea.

when an XML archive closes, it has to add some end tags - but in your case
you're closing the archive AFTER the stream has already been closed!

Try

std::wofstream datafile(wxString::Format(_T("%shuddata.prd"),
paths.GetUserLocalDataDir()).ToStdWstring().c_str());
#ifdef DATA_TO_XML
{
   boost::archive::xml_woarchive dataarchive(datafile);
   dataarchive << BOOST_SERIALIZATION_NVP(huddata);
}
#else
{
   boost::archive::text_woarchive dataarchive(datafile);
   dataarchive << BOOST_SERIALIZATION_NVP(huddata);
}
   datafile.close();
#endif

>
> Thank you very much!!!!
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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