-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sat, 29 Nov 2003 00:37:09 +0000
expatriate
praisetazio wrote:
I got this line:
... buf->lockstart = PTHREAD_MUTEX_INITIALIZER; ...
Gcc returns me an error: /home/praise/progetti/beyond/src/buffer.c:33: error: parse error before '{' token
A substitution with the following line
pthread_mutex_init(&buf->lockend, NULL);
work properly. When does the '{' come out? Am I supposed to use PTHREAD_MUTEX_INITIALIZER only at initialization?
Praise
Apparently you are correct based on what ptrhead.h shows:
#define PTHREAD_MUTEX_INITIALIZER {0, 0, 0, PTHREAD_MUTEX_TIMED_NP, __LOCK_INITIALIZER}
then you can only do something like pthread_mutex_t pmt = PTHREAD_MUTEX_INITIALIZER;
Just to add a few things. PTHREAD_MUTEX_INITIALIZER is intended for
static initialization. If you want to dynamically initialize a mutex (or
condition), you should use the appropriate function. For a mutex:
int pthread_mutex_init(pthread_mutex_t *mutex, const
pthread_mutexattr_t *mutexattr);
mutexattr can be NULL.
- --
Jerry Feldman