[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [LC++]Why doesn't PTHREAD_MUTEX_INITIALIZER work my constructor?
filiond@videotron.ca wrote:
> mutex = PTHREAD_MUTEX_INITIALIZER;
> in the class contructor I get a compilation error. If I use:
> pthread_mutex_init (&mutex, NULL);
> it works.
> [...]
> Threads::Threads ()
> {
> // This return a compilation error of:
> // Threads.cc: In method `Threads::Threads()':
> // Threads.cc:6: parse error before `{'
> //
> //mutex = PTHREAD_MUTEX_INITIALIZER;
Your guess is correct, the PTHREAD_MUTEX_INITIALIZER
macro must be evaluated and the assignment made in a
compile-time context. Try replacing the text for
PTHREAD_MUTEX_INITIALIZER directly in your code and
you might see what the compiler dislikes.
-=greg