# HG changeset patch # User Mike Becker # Date 1766359241 -3600 # Node ID aa8621b58cd7caa0605daa6de90506f61dc77803 # Parent fef6bc928c87d6d7a027c516bab4837b04b2f0f3 define own cx_thread_local macro that is compatible to C11/C17, C23, and MSVC diff -r fef6bc928c87 -r aa8621b58cd7 src/array_list.c --- a/src/array_list.c Mon Dec 22 00:20:01 2025 +0100 +++ b/src/array_list.c Mon Dec 22 00:20:41 2025 +0100 @@ -356,8 +356,8 @@ } #ifndef WITH_QSORT_R -static _Thread_local cx_compare_func2 cx_array_fn_for_qsort; -static _Thread_local void *cx_array_context_for_qsort; +static cx_thread_local cx_compare_func2 cx_array_fn_for_qsort; +static cx_thread_local void *cx_array_context_for_qsort; static int cx_array_qsort_wrapper(const void *l, const void *r) { return cx_array_fn_for_qsort(l, r, cx_array_context_for_qsort); } diff -r fef6bc928c87 -r aa8621b58cd7 src/cx/common.h --- a/src/cx/common.h Mon Dec 22 00:20:01 2025 +0100 +++ b/src/cx/common.h Mon Dec 22 00:20:41 2025 +0100 @@ -257,13 +257,22 @@ // --------------------------------------------------------------------------- -// MSVC specifics +// Support for thread_local // --------------------------------------------------------------------------- +#ifdef __cplusplus +#define cx_thread_local thread_local +#else // ! __cplusplus #ifdef _MSC_VER -// fix missing _Thread_local support -#define _Thread_local __declspec(thread) +#define cx_thread_local __declspec(thread) +#else // ! _MSC_VER +#if __STDC_VERSION__ < 202300L +#define cx_thread_local _Thread_local +#else // C23 or newer +#define cx_thread_local thread_local +#endif // C23 #endif // _MSC_VER +#endif // __cplusplus // --------------------------------------------------------------------------- // Exported and inlined functions