Pietro
Pietro

Reputation: 13182

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:

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!

Upvotes: 1

Views: 942

Answers (1)

ildjarn
ildjarn

Reputation: 62985

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.

Upvotes: 6

Related Questions