Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++11 thread_local in gcc - alternatives

As I can see at: http://gcc.gnu.org/projects/cxx0x.html thread_local keyword is unfortunately unsupported in gcc yet.

Are there any alternatives for that? I don't want to use boost library.

like image 385
Dejwi Avatar asked Feb 04 '12 16:02

Dejwi


3 Answers

The gcc compiler has a storage class __thread that might be close enough.

http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Thread-Local.html

like image 81
Bo Persson Avatar answered Oct 14 '22 14:10

Bo Persson


According to this GCC documentation page, you should try to use __thread as a qualifier (like volatile or const are) for your thread local storage.

like image 36
Basile Starynkevitch Avatar answered Oct 14 '22 16:10

Basile Starynkevitch


GCC 4.8.0 includes support for the thread_local storage class.

like image 24
Drew Noakes Avatar answered Oct 14 '22 15:10

Drew Noakes