unsigned int test() {
static _Thread_local unsigned int tl_tid;
unsigned int tid = 4;
if (tl_tid) return tl_tid;
else return tid;
}
int main() {
unsigned int rc = test();
return 0;
}
Output:
$ clang --target=arm64-apple-darwin-mach --sysroot=$SYSROOTPATH ./testthreadlocal.c
./testthreadlocal.c:2:9: error: thread-local storage is not supported for the current target
2 | static _Thread_local unsigned int tl_tid;
| ^
1 error generated.
Try to compile
Output:
clang:
clang16, clang18 generated the same error.