您的位置:首页 > Web前端

C11 の multi-thread feature

2016-06-19 20:07 567 查看
C11 标准中增加了 multi-thread 的内容:
Multi-threading support (_Thread_local storage-class specifier, <threads.h> header
including thread creation/management functions, mutex, condition variable and
thread-specific storage functionality, as well as the _Atomic type qualifier and
<stdatomic.h> for uninterruptible object access).


https://en.wikipedia.org/wiki/C11_(C_standard_revision)

但是在使用gcc编译器编译时,总提示找不到<threads.h>这个头文件, 经过查找发现,很多编译器的C库都没有
实现这部分功能,在 stackoverflow 中也有人提到这个问题:


http://stackoverflow.com/questions/24557728/does-any-c-library-implement-c11-threads-for-gnu-linux

查找C11的标准:


http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

在里面的Section "6.10.8.3 Conditional feature macros" 中有一个宏:
_ _STDC_NO_THREADS_ _ The integer constant 1, intended to indicate that
the implementation does not support the <threads.h> header.

在代码中,可以通过查看这个宏,来判断编译器是否支持C11的threads.h文件。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: