I compile this code main.c in CentOS7 with gcc:
#include
void* mystart(void* arg)
{
pthread_yield();
return(0);
}
int main(void)
{
You should use -pthread for compile and link. It not only links the library, it also sets preprocessor defines and sometimes selects a different runtime library (on Windows for example).
pthread_yield() is a non-standard function which is typically enabled by defining
#define _GNU_SOURCE
While you should use -pthread for compiling, I would expect you to get the same warning with both compilations (unless -pthread defines _GNU_SOURCE which may be the case).
The correct way to fix is to not use the non-standard function pthread_yield() and use the POSIX function sched_yield() instead by including #include <sched.h>.