我会将一些数据保存在共享内存中,使用命名信号量来管理访问:
#include <boost/interprocess/sync/named_semaphore.hpp>
struct shared_memory_buffer
{
// Application data
int items[10];
// Synchronization data
boost::interprocess::named_semaphore syncSem;
shared_memory_buffer()
: syncSem(boost::interprocess::open_or_create_t, "testSemaphore", 0) // error
{}
};
但是,我在指示的行收到以下编译时错误:
error: expected primary-expression before ‘,’ token
这是我的系统:
macOS X 10.6
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
提升 1.44
谢谢!