Hi,
I'm experiencing a runtime error while using boost's serialization for
std::map. I am defining a map like:
std::map
On 1/12/07, Mark Wyszomierski
Hi,
Hi Mark, with (very short sample app). Can anyone see what I'm doing wrong, or
if there is an error with the boost code?
No the boost code is OK. and in fact you are lucky that you get this error. If you look real closely to the "binary" output file you'll see that a byte that reads OA has been replaced by OD OA. Use std::ios::binary, or rather std::ios_base::binary, when you create the ofstream as well. hth, - levent -- Server Levent Yilmaz Mechanical Engineering @ PITT
Hi Levent,
Thanks for the quick reply. I see what you mean. Anytime I open up a
stream I now pass the ios_base::binary flag to the stream constructor.
Still the same runtime error though. All I had to do to my example was
the following, right?:
std::ofstream ofs("filename", ios_base::binary);
and
std::ifstream ifs("filename", ios_base::binary);
Thanks,
Mark
On 1/12/07, Server Levent Yilmaz
On 1/12/07, Mark Wyszomierski
wrote: Hi,
Hi Mark,
with (very short sample app). Can anyone see what I'm doing wrong, or if there is an error with the boost code?
No the boost code is OK. and in fact you are lucky that you get this error. If you look real closely to the "binary" output file you'll see that a byte that reads OA has been replaced by OD OA.
Use std::ios::binary, or rather std::ios_base::binary, when you create the ofstream as well.
hth, - levent
-- Server Levent Yilmaz Mechanical Engineering @ PITT _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 1/12/07, Mark Wyszomierski
Hi Levent,
Thanks for the quick reply. I see what you mean. Anytime I open up a stream I now pass the ios_base::binary flag to the stream constructor. Still the same runtime error though. All I had to do to my example was the following, right?:
std::ofstream ofs("filename", ios_base::binary);
yes, and with this fix your code works fine with my VC++ 7.1. (and without it it throws stream error as expected) One thing, do you get any compiler warnings related to RTTI? In 7.1 you need to turn it on (/GR switch) for serialization library to work. Then again, it should fail during output if this was the case. What exactly is the runtime error you're getting? Do you have any compilation warnings? -- Server Levent Yilmaz Mechanical Engineering @ PITT
Levent,
I'm sorry, I edited my file incorrectly. It works perfectly after your
update. Thanks for the help,
Mark
On 1/12/07, Server Levent Yilmaz
On 1/12/07, Mark Wyszomierski
wrote: Hi Levent,
Thanks for the quick reply. I see what you mean. Anytime I open up a stream I now pass the ios_base::binary flag to the stream constructor. Still the same runtime error though. All I had to do to my example was the following, right?:
std::ofstream ofs("filename", ios_base::binary);
yes, and with this fix your code works fine with my VC++ 7.1. (and without it it throws stream error as expected)
One thing, do you get any compiler warnings related to RTTI? In 7.1 you need to turn it on (/GR switch) for serialization library to work. Then again, it should fail during output if this was the case.
What exactly is the runtime error you're getting? Do you have any compilation warnings?
--
Server Levent Yilmaz Mechanical Engineering @ PITT _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Mark Wyszomierski
-
Server Levent Yilmaz