Author Topic: thread_local and dll's don't mix  (Read 1908 times)


  • Guest
thread_local and dll's don't mix
« on: April 16, 2012, 10:26:54 pm »
There's a well known problem with implicit TLS that means it doesn't work on XP or 2003 as mentioned here:

Windows Server 2003 and Windows XP:  The Visual C++ compiler supports a syntax that enables you to declare thread-local variables: _declspec(thread). If you use this syntax in a DLL, you will not be able to load the DLL explicitly using LoadLibrary on versions of Windows prior to Windows Vista. If your DLL will be loaded explicitly, you must use the thread local storage functions instead of _declspec(thread)

Pelles C's thread_local is also implemented in terms of implicit TLS and subject to the same problem. Whether the bug is a technical 'thread_local is a feature of Pelles C that should work on XP' or 'this is a limitation and should be documented in the help file or as a compiler warning' is not for me to decide.


  • Guest
Re: thread_local and dll's don't mix
« Reply #1 on: April 17, 2012, 07:37:00 pm »
Oh, this is sort of documented. It's under the /GA command line switch help