Problem about initialize a mutex object in a class

Kun Niu haoniukun@gmail.com
Mon May 7 04:41:00 GMT 2007


Dear all,
I've been recently writing a thread based library with pthread on Linux.
I've got a class like this:

class Thread
{
private:
  pthread_mutex_t thread_mutex;
public:
  Thread();
}

Thread::Thread() : thread_mutex(PTHREAD_MUTEX_INITIALIZER)
{
}

But when I'm compiling the code. g++ told me:
error: expected primary-expression before '{' token

My g++ version is  4.1.2.
I can't initialize a struct that way. Right?
Since it's the only place I can use to initialize a struct.

Thanks for any help.
Regards



More information about the Gcc-help mailing list