Here is a little C source code using pthread_kill() call:
#include <stdlib.h>
#include <pthread.h>
#include <signal.h>
int main(int argc, char *argv[])
{
pthread_t th = NULL;
pthread_kill(th, 0);
return 0;
}
Gcc compilation produces various results depending on -std argument value (see below). I don't understand these different behaviors. I didn't get interesting informations into man pages except pthread_kill() is POSIX.1-2008 compliant.
Environment: Linux 3.2 64bits. GCC 4.7.2.
With -std=c11
gcc main.c -std=c11 -pthread
I get an implicit declaration:
main.c:9:2: warning: implicit declaration of function ‘pthread_kill’ [-Wimplicit-function-declaration]
With -std=c99
gcc main.c -std=c99 -pthread
Same result as -std=c11:
main.c:9:2: warning: implicit declaration of function ‘pthread_kill’ [-Wimplicit-function-declaration]
With -std=c90
gcc main.c -std=c90 -pthread
It simply works without any errors/warnings.
Thank you for your feedbacks.
-lpthreadinstead of-pthread?-std=gnu99or e.g.-std=gnu11flags that gives you extension to the respective C standard, which includes library features such as posix functions if you are using glibc on linux.