I am trying to setup a c11 thread example in xcode... but it doesn't seem to have the threads.h header, though it isn't complaning about the macro described here:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
__STDC_NO_THREADS__The integer constant 1, intended to indicate that the implementation does not support the <threads.h> header.
Looks like almost nothing supports the threads feature in C11... maybe I will try to get it into clang...
With the clang on my machine (v. 3.2 on ubuntu/linux) that feature test macro isn't defined. Support for that feature will need support in the C library, that usually doesn't come with the compiler. So basically the answer for clang will not be much different than for gcc, they usually build upon the same C library, namely glibc, see here for answer for gcc.
Just in case anyone is looking this up in 2021+, Apple still doesn't support this, and likely never will. As others have stated, pthreads
is by far the best bet. Note that widely, C11 threads are not supported. I would go as far as to say pthreads
is more portable in most circumstances.
From a development perspective, C11 threads are much too limited, and obfuscate user space vs. kernel space implementation features, along with implementation attributes.
If you really need C11 threads I would recommend doing one of three things.
The good thing to note is some other C11 features are supported on OSX, like C11 Atomics, which complementing would be impossible without a lot of ASM knowledge.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With