Why implicit declaration of pthread_yield with -lpthread while all ok with -pthread?

后端 未结 2 1489
攒了一身酷
攒了一身酷 2021-01-17 22:02

I compile this code main.c in CentOS7 with gcc:

#include 
void* mystart(void* arg)
{
    pthread_yield();
    return(0);
}
int main(void)
{
         


        
2条回答
  •  时光说笑
    2021-01-17 22:40

    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).

提交回复
热议问题