thread-private variable in C


I’m wondering if pgcc has a language extension like __thread to declare a variable as thread-private. Although non-standard, __thread is already supported by gcc, icc, [bg]xlc, oracle’s cc, clang, open64, fcc[px], cray’s cc.

I could emulate __thread using Pthreads, but a language extension would be far more convenient. Using OpenMP’s threadprivate is not an option here.

I tested __thread with pgcc 10.1-0 and 13.9-0. They both refuse the line

static __thread int threadlocal_foo;

(which is inside a function).

Is there anything similar to __thread in pgcc?


Hi Christian,

Sorry, but we don’t support the Thread-Local Storage extension as of yet. We do get a few requests for it once in a great while so I went ahead and added feature request (TPR#19737). I’m not sure when we would add it, but the request should at least get it on a future road-map.