【发布时间】:2015-11-17 10:29:59
【问题描述】:
我在 CentOS7 中用 gcc 编译了这段代码 main.c:
#include <pthread.h>
void* mystart(void* arg)
{
pthread_yield();
return(0);
}
int main(void)
{
pthread_t pid;
pthread_create(&pid, 0, mystart, 0);
return(0);
}
第一次编译:gcc -Wall -g main.c -pthread -o a.out
没关系。
第二次编译:gcc -Wall -g main.c -lpthread -o a.out
给
警告:函数“pthread_yield”的隐式声明 [-Wimplicit-function-declaration]
- 第二个
a.out还能正常运行吗? - 如何在没有
-pthread的情况下修复警告?sched_yield是产生 pthread 的另一种方式吗?
【问题讨论】:
-
“如何在没有
-pthread的情况下修复警告?”自己提供缺少的原型。 -
我无法在 CentOS 7 上重现这个,两者都在此处给出警告。