Pthread Mutex Init Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn pthread mutex example more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags pthread mutex attributes Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, pthread mutex initializer helping each other. Join them; it only takes a minute: Sign up pthread_mutex_t init error up vote 4 down vote favorite I am using xcode 2.4.1 on tiger. When i do below everything is ok. when i do pthread mutex init example pthread_mutex_t mute; ImageMan() { dibSize=0; mute = PTHREAD_MUTEX_INITIALIZER; } I get these two errors error: expected primary-expression before '{' token error: expected `;' before '{' token I dont know why. However if i do pthread_mutex_t mute = PTHREAD_MUTEX_INITIALIZER; it works fine. Why? -edit- I havent ran it but this seems to compile. Why? huh? pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; mute = mutex; initialization pthreads mutex share|improve this question asked Dec 20 '08 at 13:04 acidzombie24 43k137456818 add
Pthread Mutex Example C++
a comment| 2 Answers 2 active oldest votes up vote 15 down vote accepted PTHREAD_MUTEX_INITIALIZER is a constant initializer, valid when in initialization only. It is a macro that doesn't necessarily expand to an integral type. Your mute=mutex; is invalid- instead you should use: pthread_mutex_init(&mute, NULL); or if you're allocating mutexes dynamically: m = malloc(sizeof(pthread_mutex_t))); pthread_mutex_init(m, NULL); share|improve this answer answered Dec 20 '08 at 13:54 geocar 7,0891730 add a comment| up vote 0 down vote mute = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER; This is an another solution for this error. share|improve this answer answered Jul 10 '15 at 6:11 raja ashok 3,726103761 Always try to give some explanation of answer. –serenesat Jul 10 '15 at 19:34 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged initialization pthreads mutex or ask your own question. asked 7 years ago viewed 8817 times active 1 year ago Blog Stack Overflow Podcast #92 - The Guerilla Guide to Interviewing Get the weekly newsletter! In it, you'll get: The week's top questions and answers Important comm
Mutex ConsistentInitialize a Mutex pthread_mutex_init(3THR) Use pthread_mutex_init(3THR) to initialize the mutex pointed at by mp to its default value (mattr is NULL), or to specify https://docs.oracle.com/cd/E19455-01/806-5257/sync-112/index.html mutex attributes that have already been set with pthread_mutexattr_init(). (For Solaris http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/p/pthread_mutex_init.html threads, see "mutex_init(3THR)".) Prototype: int pthread_mutex_init(pthread_mutex_t *mp, const pthread_mutexattr_t *mattr); #include
Virtualization Wireless Framework Bluetooth Acoustics Apps and Media Tools BSP Directory Services Professional Services Training & Education Consulting & Programs Automotive Services Markets Markets Automotive Industrial Medical Networking & Telecoms Security & Defense Rail Safety Developers Developers Developer community Product documentation BSP directory Reference design + demos Downloads QNX Download Center QNX CAR 2.1 SDK for Apps and Media 1.1 QNX Software Development Platform 6.6 QNX Wireless Framework 1.0 Quickstart development guide System Architecture guide FREE 30 day Evaluation Partners Partners Strategic partners Distributors Medical Support Support Overview Support options Support portal Knowledge base Product documentation Developer community Developer Resources Board support packages Foundry27 projects Forums HomeDeveloper ResourcesDeveloper SupportQNX Developer Support PDF Documents QNX Neutrino RTOS Quickstart Guide System Architecture Guide Standard Support User's Guide Priority Support User's Guide This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. pthread_mutex_init() Initialize mutex Synopsis: #include