我尝试使用boost 1.58进程间库在进程之间共享内存,并且需要它来支持32位和64位进程。
我一直在关注boost邮件列表中的建议以使其工作,但我在Visual c + +(2013年和2015年)上获得了32位版本(仅在那里)的编译错误。
这是暴露编译错误的最小样本:
#include <boost/interprocess/offset_ptr.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <cstdint>
namespace bi = boost::interprocess;
typedef bi::offset_ptr<void, std::int32_t, std::uint64_t> VoidPointerT;
typedef bi::basic_managed_shared_memory<char, bi::rbtree_best_fit<bi::mutex_family, VoidPointerT>, bi::iset_index> my_managed_shared_memory;
int main()
{
my_managed_shared_memory shm(bi::open_or_create, "test", 1024);
return 0;
}
我得到的错误是:
error C2719: 'x': formal parameter with __declspec(align('8')) won't be aligned
在许多不同的提升标题中。
据我所知,我可以通过逐个引用来替换报告函数中的call-by-value参数来修复此错误,但在我的实际应用程序中,问题发生在整个库中的几十个地方。还有更好的方法吗?