c++11 thread_local keyword support in visual studio 11

Eloff picture Eloff · Jan 7, 2012 · Viewed 10.6k times · Source

So there's a list of c++11 features supported by visual studio.

thread_local support is marked as partial. I was unable to find an explanation of what exactly partial support means here. Did they just alias __declspec(thread)?

I could just use boost::thread_specific_ptr, but there seem to be some reports that boost::thread_specific_ptr is slow. That may or may not be true.

Specifically I want fast TLS on x86/x64 on the most recent linux+gcc and windows+msvc. Fast meaning no system calls where possible (I think this is possible for the platforms above.)

Answer

Eloff picture Eloff · Jan 7, 2012

So I did some digging into thread_local semantics. gcc's __thread and msvc's __declspec(thread) have the same semantics as each other and thread_local (dynamic initialization aside, which may or may not have made it into the standard yet.) So this is really a non-issue for my use case. I'll just make a define that aliases one or the other platform specific attribute.