ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Iam suppose to use recursive mutex in my code but, iam getting following error while compiling. Iam working on linux platform. Wil somebody help on this...!!
error: ‘PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP’ undeclared here (not in a function)
Um... What language are you using? Can you reduce your source code to a small file which doesn't work, illustrating simply the error you're generating, and then post it?
You're probably using C or C++...
... and you probably need to declare "PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP" as a global, "extern" variable in a .h header file. For example:
I thought "PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP" was probably a user-defined global variable. But you're right - it's a pthreads variable. Specifically, a pthreads enumeration:
pthread.h =>
Please give us more details about what you're doing, just as Snark1994 asked. What language are you using? How are you using "PTHREAD_MUTEX_RECURSIVE_NP"? Can you provide code snippets?
Also: have you #include'ed <pthread.h>? That's kind of important if you're writing a pthreads program (at least if you're writing it in C or C++)
Sorry for the late response...!! Iam using C program in linux platform. I have included pthread.h in the source file and again i declared "PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP" as a global variable.
Instead of "PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP" this if i use "PTHREAD_MUTEX_INITIALIZER" it is compiling correctly but i need recursive mutex. I also tried defining _GNU_SOURCE in the code but there is no improvement...!!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.