diff --git a/osdep/compiler.h b/osdep/compiler.h index cb04fed81f..48693154ce 100644 --- a/osdep/compiler.h +++ b/osdep/compiler.h @@ -22,6 +22,10 @@ #define MP_UNUSED #endif +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ < 202311L) && !defined(thread_local) +#define thread_local _Thread_local +#endif + #if defined(__GNUC__) || defined(__clang__) #define PRINTF_ATTRIBUTE(a1, a2) __attribute__((format(printf, a1, a2))) #define SCANF_ATTRIBUTE(a1, a2) __attribute__((format(scanf, a1, a2))) diff --git a/osdep/io.c b/osdep/io.c index f7e24ba29a..5167b104a9 100644 --- a/osdep/io.c +++ b/osdep/io.c @@ -721,7 +721,7 @@ int mp_ftruncate64(int fd, off_t length) return -1; } -_Thread_local +thread_local static struct { DWORD errcode; char *errstring; diff --git a/osdep/threads.h b/osdep/threads.h index 4e9cf97baf..0e607598ff 100644 --- a/osdep/threads.h +++ b/osdep/threads.h @@ -9,4 +9,6 @@ #include "threads-posix.h" #endif +#include "osdep/compiler.h" // for thread_local + #endif