如何初始化互斥锁和条件变量
pthread_mutex_t qlock[5] = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t qcond[5] = PTHREAD_COND_INITIALIZER;
它给我错误如下...
错误:数组必须用大括号括起来的初始化程序初始化
..请有人调试这个或告诉我解决它的方法...
pthread_mutex_t qlock[5] = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t qcond[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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这初始化了一个互斥体:
这初始化了一个数组:
...这应该足以让你继续下去。
This initializes a mutex:
This initializes an array:
...that should be enough to get you going.
我建议你阅读一本关于 C 编程语言的入门书。例如,请参阅相关的SO问题。
顺便说一句,在这个 C 知识水平上,我强烈建议您远离多线程编程(至少使用 pthreads)。
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).