开发者

Bug in code using boost named_semaphore

I would keep some data in shared memory, using named semaphores to manage access:

#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
    {}
};

However I get the following compile time error at the indicated line:

err开发者_Go百科or: expected primary-expression before ‘,’ token

This is my system:

MacOS X 10.6

i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)

Boost 1.44

Thank you!


boost::interprocess::open_or_create_t is a type – you presumably want to pass boost::interprocess::open_or_create, which of course is an instance of open_or_create_t. This is documented here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜