开发者

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

This question already has answers here: Cl开发者_JAVA技巧osed 11 years ago.

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜