diff --git a/libcpuid/cpuid_main.c b/libcpuid/cpuid_main.c index 3551a17..8470412 100644 --- a/libcpuid/cpuid_main.c +++ b/libcpuid/cpuid_main.c @@ -38,7 +38,13 @@ /* Implementation: */ -static int _libcpiud_errno = ERR_OK; +#if defined(__STDC_VERSION__) && __STDC_VERSION__ == 201112L + _Thread_local int _libcpiud_errno = ERR_OK; +#elif defined(__GNUC__) // Also works for clang + __thread int _libcpiud_errno = ERR_OK; +#else + static int _libcpiud_errno = ERR_OK; +#endif int set_error(cpu_error_t err) {