Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C - Implicit declaration of the function "pthread_timedjoin_np"

I am porting a windows library to linux. I need to use timed join to wait for the thread to join in a specific timeout.

When I compile the library on Linux I am getting the warning

Implicit declaration of the function - pthread_timedjoin_np

I have included pthread.h and have compiled with -lpthread link. I know that pthread_timedjoin_np is a non-standard GNU function. The function first appeared in glibc in version 2.3.3. and somewhere in BCD v6.

I even checked the Man Page for Linux but got no help. How do I avoid this warning? Any help?

Edit-1: My system is RedHat 5.

like image 614
jparthj Avatar asked Feb 25 '14 12:02

jparthj


1 Answers

Make sure the #define _GNU_SOURCE is before any of the your headers are included. Macros are set up by <features.h>, which include various parts of the GNU C library. If you've included other headers before you define _GNU_SOURCE, <features.h> will have already been included and will have not seen _GNU_SOURCE.

Even easier, just define it with the compiler adding -D_GNU_SOURCE as a compiler flag.

like image 157
Collin Avatar answered Sep 30 '22 00:09

Collin