C++ Boost进程间Win32,x64

C++ Boost进程间Win32,x64,c++,boost,platform,interprocess,boost-interprocess,C++,Boost,Platform,Interprocess,Boost Interprocess,我想使用boost interprocess在不同平台之间进行通信 我在Windows7上使用vc12和boost 1.58 我下面的代码是一个非常简单的示例,应该可以工作。但它不适用于不同平台之间的通信 如果我在x64中创建msm并在win32中打开,则进程在boost/int/sync/detail/common_algorithms.hpp中的函数try_-based_-lock处被锁定 另一种方法是:win32 create,x64 open:当试图在索引中查找名称时,进程在段管理器中的

我想使用boost interprocess在不同平台之间进行通信

我在Windows7上使用vc12和boost 1.58

我下面的代码是一个非常简单的示例,应该可以工作。但它不适用于不同平台之间的通信

如果我在x64中创建msm并在win32中打开,则进程在boost/int/sync/detail/common_algorithms.hpp中的函数try_-based_-lock处被锁定

另一种方法是:win32 create,x64 open:当试图在索引中查找名称时,进程在段管理器中的name_长度处崩溃(在段管理器中的priv_generic_find)

问题发生在msm.find(“数据”)上

#包括
#包括
int main(){
名称空间bip=boost::进程间;
//在WIN32中打开,在x64中创建
#ifndef\u WIN64
bip::托管共享内存msm(bip::仅限open_,“TestIPC”);
#否则
bip::共享_内存_对象::删除(“TestIPC”);
bip::托管共享内存msm(bip::仅创建共享内存,“TestIPC”,4096);
msm.构造(“数据”)[1](10);
#恩迪夫
//获取数据并打印出来
自动数据=msm.find(“数据”);
如果(data.second==1){

std::cout
boost::进程间
使用托管共享内存类的32位和64位模式之间的通信似乎不受支持,或者是一个错误。但在较低级别上,它工作正常。以下是示例代码:

#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <iostream>

int main(int argc, char *argv[])
{
    using namespace boost::interprocess;

#ifndef _WIN64
    shared_memory_object shm(open_only, "MySharedMemory", read_write);
    mapped_region region(shm, read_only);
    uint8_t *ptr = static_cast<uint8_t*>(region.get_address());
    std::cout << int32_t(*ptr) << std::endl;
#else
    shared_memory_object shm(create_only, "MySharedMemory", read_write);
    shm.truncate(4096);
    mapped_region region(shm, read_write);
    uint8_t *ptr = static_cast<uint8_t*>(region.get_address());
    *ptr = 5;
#endif

    return 0;
}
#包括
#包括
#包括
int main(int argc,char*argv[])
{
使用名称空间boost::interprocess;
#ifndef\u WIN64
共享内存对象shm(仅打开“MySharedMemory”,读写);
映射的_区域(shm,只读);
uint8_t*ptr=static_cast(region.get_address());
std::是否有未定义的_WIN32。这可能会影响boost库。
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <iostream>

int main(int argc, char *argv[])
{
    using namespace boost::interprocess;

#ifndef _WIN64
    shared_memory_object shm(open_only, "MySharedMemory", read_write);
    mapped_region region(shm, read_only);
    uint8_t *ptr = static_cast<uint8_t*>(region.get_address());
    std::cout << int32_t(*ptr) << std::endl;
#else
    shared_memory_object shm(create_only, "MySharedMemory", read_write);
    shm.truncate(4096);
    mapped_region region(shm, read_write);
    uint8_t *ptr = static_cast<uint8_t*>(region.get_address());
    *ptr = 5;
#endif

    return 0;
}