Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the C++ boost binary serialization library backward/foward compatible? [duplicate]

Possible Duplicate:
Boost Serialization Library upgrade

I am trying to find a serialization solution for a C++ application. I would really like to be able to use boost binary serialization. If I were to serialize an object using an older version of the boost binary serialization library, will an application that is using a newer version of the boost library always be able to read it? What about vice versa? What is boost's philosophy on backward/compatibility on the serialization library?

like image 698
Andrew Avatar asked Sep 28 '11 12:09

Andrew


1 Answers

They do it by incrementing the version in the header. So yes, it's compatible in a sense that you will get a graceful failure if you try to read binary data serialized with incompatible version as 1.45.0 release notes tend to indicate. Moreover there are bugs in 1.42 and 1.43 that break it!

Native binary archives created under versions 1.42 and 1.43 suffer from a serious problem. It's likely they won't be readable by this latest version. This due to the fact that 1.42 made some changes in the binary format of some types. Normally this could be addressed by detecting the library version number written into the archive header. Unfortunately, this library version number was not incremented at 1.42 as it should have been. So now we have two different binary archive versions with the same library version number.

I personally would put more faith in Google Protocol Buffers, it explicitly maintains backwards compatibility:

You can add new fields to your message formats without breaking backwards-compatibility; old binaries simply ignore the new field when parsing.

However it requires a bit more effort on the build system side as it involves using auto-generated code.

like image 171
Alex B Avatar answered Nov 15 '22 22:11

Alex B