Thread-Local Storage

From dankwiki
Jump to navigation Jump to search

C99

  • ISO/IEC 9899:1999 is amended by gcc and others to introduce the __thread storage specifier (§6.2.4, §6.4.1, §6.7.1), and to add a vague definition of threads to the execution model (§5.1.2).

C++11

  • C++11 adds the thread_local keyword
    • Only constant initializers can be used for variables having __thread storage.

Windows

  • __declspec(thread) doesn't work in DLL's prior to Vista when loaded via LoadLibrary().
    • The DLL must be linked into the binary before the binary's main image is loaded.

See Also