Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::serialization "input stream error" inrelease-build (msvc2010)
From: Jens Saathoff (jensesaat_at_[hidden])
Date: 2012-05-23 06:14:47


Hi Robert!

Currently i'm not using the XML-Archive. Did not define DATA_TO_XML, so the
text-archive is used.
But the main thing....i found the error. I did not initialize all members.
No problem in debug-builds, but deadly for release-builds.

Shall i remove the explicit datafile.close(); also for text-archives and
let the function just return to do correct destruction?

Thank you very much!

2012/5/22 Robert Ramey <ramey_at_[hidden]>

> 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 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