After I declared a variable in this way:
#include <thread>
namespace thread_space
{
thread_local int s;
} //etc.
i tried to compile my code using 'g++ -std=c++0x -pthread [sourcefile]'. I get the following error:
example.C:6:8: error: thread-local storage is unsupported for the current target
static thread_local int s;
^
1 error generated.
If i try to compile the same code on Linux with GCC 4.8.1 whit the same flags, i get a functioning executable file. I'm using clang-503.0.40 (the one which comes with Xcode 5.1.1) on a MacBook Pro running OSX 10.9.3. Can anybody explain me what i'm doing wrong? Thank you!!
g++ -std=c++0x ...
then you are NOT using clang - you are using the extremely outdated version of GCC that ships with MacOS. Tryclang++ -std=c++11 ...
instead. – WifePier$ clang++ -std=c++11 -lpthread ./example.C ./example.C:6:1: error: thread-local storage is unsupported for the current target thread_local int s; ^
– Flamethrowerg++
is just a wrapper aroundclang++
on OS X 10.9+. – Heriberto