gcc 4.9.0 安装后,无法编译 C11程序,能编译 C++2011,缺 threads.h

hzhxxx hzhxxx 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
gcc 4.9.0 安装后,无法编译 C11程序,能编译 C++2011,缺 threads.h
详细情况见:
http://blog.csdn.net/hzhxxx/article/details/28634893

代码:
3.6. 验证编译功能(C11),缺少 threads.h文件,编译失败
创建文件test_gcc4.9.c,内容如下:
#include <string.h>
#include <stdio.h>
#include <threads.h>

void * fun(void *data)
{
printf("dddd\n");
return 0;
}

int main(int argc,char *argv[])
{
thrd_t loc;
thrd_create(&loc, fun,0);
thrd_join(loc,0);
return 0;
}

编译执行,注意看参数 -std=c11,-lgcc_s,证明是使用新标准
查看链接的动态库,是新的库
呜呼,无法编译成功,无法执行正常!!!
#/usr/local/gcc-4.9.0/bin/gcc -Wwrite-strings -std=c11 test_gcc4.9.c -o test_gcc4.9 -I/usr/local/gcc-4.9.0/include -L/usr/local/gcc-4.9.0/lib64 -lgcc_s -lpthread;
#test_gcc4.9.c:4:21: 致命错误:threads.h:没有那个文件或目录
#include <threads.h>
^
编译中断。
...全文
评论 30
收藏 已收藏
分享
返回顶部
hzhxxx
C语言 70,039 成员 243,237 内容