开发者

How do I initialize the mutex locks and condition variables

开发者 https://www.devze.com 2023-04-10 04:02 出处:网络
pthread_mutex_t qlock[5] = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t qcon开发者_JS百科d[5] =PTHREAD_COND_INITIALIZER;

pthread_mutex_t qlock[5] = PTHREAD_MUTEX_INITIALIZER;

pthread_cond_t qcon开发者_JS百科d[5] = PTHREAD_COND_INITIALIZER;

It is giving me error as follows...

error: array must be initialized with a brace-enclosed initializer

.. Please, can somebody debug this or tell me a way to solve it...


This initializes a mutex:

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

This initializes an array:

int array[5] = { 0, 1, 2, 3,  4 };

...that should be enough to get you going.


I'd suggest you reading a beginner book on C programming language. See for example a related SO question.

BTW, at this level of C knowledge I would highly recommend you to stay away from multithreaded programming (at least with pthreads).

0

精彩评论

暂无评论...
验证码 换一张
取 消