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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With