The following C code:
__declspec(dllexport) __declspec(thread) int xxx = 3;
fails to compile with VC with:
test.c(2): error C2492: 'xxx': data with thread storage duration may not have dll interface
So it looks like we can't reasonably make that work for D on Windows. The `export` will have to be ignored, because making it an error will make it clumsy to use `export:` attributes.
Comment #1 by dlang-bot — 2023-06-05T07:56:52Z
@WalterBright created dlang/dmd pull request #15296 "fix Issue 23969 - Windows cannot export/import TLS from DLLs" fixing this issue:
- fix Issue 23969 - Windows cannot export/import TLS from DLLs
https://github.com/dlang/dmd/pull/15296
Comment #3 by alphaglosined — 2023-06-05T11:25:41Z
(In reply to Walter Bright from comment #2)
> TL/DR: exporting TLS from DLLs causes a system crash.
But only on operating systems below Vista, which we don't support.
However in saying that, we should probably disallow exporting of TLS variables anyway as it'll be platform/libc dependent and that could get old very fast trying to figure out why your application doesn't work when ported. Only then to have to rewrite everything.
Comment #4 by bugzilla — 2023-06-05T23:37:55Z
Microsoft VC will not compile:
__declspec(dllexport) __declspec(thread) int x = 3;
Comment #5 by robert.schadek — 2024-12-13T19:29:31Z