[serialization] Cross-compiled binary archive

Hi all, I need to make a modified version of binary archive so that it can read data serialized on a different platform. Specifically, I have a lot of files written with binary serializer on x86, and now I need to read them into application built on x64 platform ( sizeof(size_t) == 8 ). Obvious place to fix would be the load() functions in boost\archive\impl\basic_binary_iprimitive.ipp, replacing the std::size_t declaration with unsigned int. Are there less obvious places in the archive format that are dependent on the pointer size ? Thanks

That's the obvious place. I don't think anything is dependent upon pointer size - as pointers themselves are not stored. I suspect the problem will be when using integers - I would expect the sizes of these to change when moving to 64 bit platforms. After all size_t is an integer. If it were me I would just forget it. The best would be to just convert the binary archives into portable binary archives or something else. That is, if you want portability - don't use binary archive which optimized for speed. Robert Ramey Zrubavel Zodikovich wrote:
Hi all,
I need to make a modified version of binary archive so that it can read data serialized on a different platform. Specifically, I have a lot of files written with binary serializer on x86, and now I need to read them into application built on x64 platform ( sizeof(size_t) == 8 ).
Obvious place to fix would be the load() functions in boost\archive\impl\basic_binary_iprimitive.ipp, replacing the std::size_t declaration with unsigned int.
Are there less obvious places in the archive format that are dependent on the pointer size ?
Thanks
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Thanks, Robert, that worked. I'll summarize the case here in case anyone encounters similar problem. We needed to read binary archives created on a different platform. Changing the code to use portable_binary_archive was not an option - the data was already written to disk. The problem turned out to be in string serialization code, which depended on the size of std::size_t type. Therefore, replacing the std::size_t with unsigned int in these two files allowed us to read the archive on 64 bit platform. * boost\archive\impl\basic_binary_iprimitive.ipp * boost\archive\impl\basic_binary_oprimitive.ipp The sizes of different types on our platforms were as follows : type vc8 vc8-x64 ------ ------ ------- void* 4 8 size_t 4 8 int 4 4 Robert Ramey wrote:
That's the obvious place.
I don't think anything is dependent upon pointer size - as pointers themselves are not stored.
I suspect the problem will be when using integers - I would expect the sizes of these to change when moving to 64 bit platforms. After all size_t is an integer. If it were me I would just forget it. The best would be to just convert the binary archives into portable binary archives or something else. That is, if you want portability - don't use binary archive which optimized for speed.
Robert Ramey
participants (2)
-
Robert Ramey
-
Zrubavel Zodikovich