升压binary_oarchive对于不同的编译器的工作方式不同 [英] boost binary_oarchive works differently for different compilers
问题描述
我需要客户端和服务器之间传输数据。当我把服务器从Windows(msvc140)给Debian(GCC 64位),我根据升压
有一个问题,我的字节流类。他们的档案是不同的。
I need to transfer data between client and server. When I moved server from Windows (msvc140) to Debian (gcc 64-bit) I've got a problem with my byte stream class based on boost
. Their archives are different.
#include <string>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/iostreams/device/back_inserter.hpp>
#include <boost/iostreams/stream.hpp>
int main()
{
std::string s;
typedef boost::iostreams::back_insert_device<std::string> BackInsertDevice;
typedef boost::iostreams::stream<BackInsertDevice> Stream;
typedef boost::archive::binary_oarchive BinaryOArchive;
Stream stream(s);
BinaryOArchive ar(stream);
ar << "qwer" << 10;
stream.flush();
int sz = s.size();
// Windows (msvc140): 49
// Debian (gcc 64-bit): 57
}
升压
是两个版本1.61.0
Both versions of boost
are 1.61.0
推荐答案
这就是证明。的http://www.boost.org/doc/libs/1_49_0/libs/serialization/doc/todo.html#portablebinaryarchives
有没有携带档案升压本身。
There is no portable archive in Boost itself.
您想看看EOS便携档案:的https://epa.$c$cplex.com/
You want to look at EOS Portable Archives: https://epa.codeplex.com/
他们很容易在你的code碱基下降,转而使用的boost ::存档:: binary_ [IO]存档
They're very easy to drop in your code base and use instead of boost::archive::binary_[io]archive
这篇关于升压binary_oarchive对于不同的编译器的工作方式不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!