C11 GCCthreads.h 未找到?

标签 c multithreading c11

以下代码

#include <threads.h>

给我这个错误:

fatal error: threads.h: No such file or directory

使用最新的 GCC 和 Clang 以及 -std=c11。

GCC 和 Clang 不支持 C11 线程吗?或者是否有黑客(或需要安装的东西)来获取它?我只是使用 Ubuntu 14.04 以及 Ubuntu 存储库中的 gcc 和 clang 软件包。

最佳答案

gcc 文档 C11 status表明它不支持线程,它说:

Threading [Optional] | Library issue (not implemented)

正如文档所示,这实际上并不是 gccclang 问题,而是 glibc 问题。正如扎克指出的那样,它看起来像 there may be work under way soon获得对 glibc 的支持,但这现在对你没有帮助。 您可以使用this在此期间。

已修复 glibc 2.28

根据Bug 14092 - Support C11 threads这在 glibc 2.28 中已修复:

Implemented upstream by:

9d0a979 Add manual documentation for threads.h
0a07288 nptl: Add test cases for ISO C11 threads
c6dd669 nptl: Add abilist symbols for C11 threads
78d4013 nptl: Add C11 threads tss_* functions
918311a nptl: Add C11 threads cnd_* functions
3c20a67 nptl: Add C11 threads call_once functions
18d59c1 nptl: Add C11 threads mtx_* functions
ce7528f nptl: Add C11 threads thrd_* functions

It will be included in 2.28.

关于C11 GCCthreads.h 未找到?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34806246/

相关文章:

c - while 循环和嵌套 if 不能一起工作

c - 为什么这个 C 程序在 VC++2008 中返回正确的值?

java - 这两个示例是否等效( volatile +同步增量与同步获取+增量)?

c - 未定义行为的不同分类是什么意思?

c - 外部内联风险

c - DRY 如何与 "Separation of concern"和 "One function, one task"组合?

C 编程中二元运算符错误

java - 我的 Java 缓存线程安全且高效吗?

.net - 使用.NET 5 CancellationToken调用可以在主线程上超时的方法

c - __atomic_load_n 和 __atomic_load 之间的区别