Pietro Pietro - 1 year ago 138
C++ Question

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;

: syncSem(boost::interprocess::open_or_create_t, "testSemaphore", 0) // error

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

error: 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!

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download