Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
846 views
in Technique[技术] by (71.8m points)

c - C11 GCC threads.h not found?

The following code

#include <threads.h>

Gives me this error:

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

Using the latest GCC and Clang with -std=c11.

Is C11 threading not supported by GCC and Clang? Or is there a hack (or something to install) to get it? I'm just using Ubuntu 14.04 with the gcc and clang packages from the Ubuntu repo.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The gcc document C11 status indicates that it does not support threading, it says:

Threading [Optional] | Library issue (not implemented)

As the document indicates this is not really a gcc or clang issue but glibc issue. As Zack pointed out it looks like there may be work under way soon to get support for this into glibc but that won't help you now. You can use this in the meantime.

Fixed for glibc 2.28

According the Bug 14092 - Support C11 threads this is fixed in 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...