嗨,我需要在linux上构建一个项目,但是它使用"boost/interprocess/windows_shared_memory.hpp“是在linux上运行它的任何方式,还是我必须重写这段代码?
谢谢
发布于 2013-08-07 12:22:52
我觉得你只需要用
#include <boost/interprocess/managed_shared_memory.hpp>而不是boost/interprocess/windows_shared_memory.hpp。这将同时处理Windows和Linux。
发布于 2013-08-07 12:25:44
您不能为您的Linux平台使用特定于windows的代码,但是可以使用少量的#ifdef __WIN32__//#else//#endif和一些合适的ty胡枝子或者类似于在Linux上使用标准(非windows)共享内存体系结构。
您应该能够使用常规的共享内存体系结构,而无需对现有代码进行任何或最小的修改。
比较:0/doc/html/interprocess/sharedmemorybetweenprocesses.html与(同一页下一节) 内存
发布于 2013-08-07 12:24:41
如果你看上去像这里,你会看到:
#if !defined(BOOST_INTERPROCESS_WINDOWS)
#error "This header can only be used in Windows operating systems"
#endif所以,是的,您需要移植它才能在linux上运行。
https://stackoverflow.com/questions/18103168
复制相似问题