How to declare a variable as thread local portably?
问题 C11 introduces the _Thread_local storage class specifier that can be used in combination with the static and extern storage class specifiers to declare a variable as thread local. The GNU C compiler suite implements a storage class specifier __thread with the same same semantics. Unfortunately I did not find any compiler (I tried gcc, clang and SUN studio) that actually implements the _Thread_local keywords. I currently use the following construct to declare a keyword thread_local : /* gcc