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
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;
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sat, 29 Nov 2003 00:37:09 +0000 expatriate <lbox@nellgc.plus.com> wrote:
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 <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQE/yN3Y+wA+1cUGHqkRArwWAJ9iZLZN7CCSbMNnZ/UJzxxcnIdzagCfedve CqP65b5A6oYWbgYFqHL9zps= =8jHB -----END PGP SIGNATURE-----
participants (3)
-
expatriate
-
Jerry Feldman
-
praisetazio