Boost 序列化在 32 位和 64 位机器之间不起作用.任何其他序列化/压缩库? [英] Boost serialization does not work between 32bit and 64bit machine. Any other serialization / compression library?

查看:32
本文介绍了Boost 序列化在 32 位和 64 位机器之间不起作用.任何其他序列化/压缩库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 boost 库在 64 位机器上序列化并在 32 位机器上反序列化.但是,它似乎不起作用.(我使用 1.57.0).

I am trying to use the boost library to serialize on 64bit machine and de-serialize on 32bit machine. However, it seems it does not work. (I use 1.57.0).

如果我运行以下代码

boost::asio::streambuf buf;
std::ostream os(&buf);
boost::archive::binary_oarchive oa(os);
printf("Buffer size %d
",(int)buf.size());

32位机输出37,64位机输出41.

The output of 32bit machine is 37 and the output of 64bit machine is 41.

还有其他好的序列化库可以使用吗?麦片怎么样?

Is there any other good serialize library I can Use? How about cereal?

如果库也可以进行压缩(zlib/gzip 等),那就太好了.

It's great if the library can do compression as well (zlib/gzip etc.).

推荐答案

确实有效.它只是不创建兼容的档案.如果你想要,你应该看看 EOS 的归档实现:

It does work. It just doesn't create compatible archives. If you want that you should look at the archive implementation that EOS made:

您可以直接用它替换 Boost 的 binary_[io] 存档.无需更改任何其他内容.

You can drop-in replace Boost's binary_[io]archive with it. No need to change anything else.

附注.当然,当然,也要以与体系结构无关的方式说明您的类型.所以uint32_t,而不是``size_t`

PS. Of course, spell out your types in an architecture-independent way too, of course. So uint32_t, not ``size_t`

这篇关于Boost 序列化在 32 位和 64 位机器之间不起作用.任何其他序列化/压缩库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆