[numerics] try to be careful with C11 and TLS
#endif
-#ifndef __cplusplus
+#if !defined(__cplusplus) || !defined(BUILD_AS_CPP)
#ifdef SWIG
#define tlsvar
- #elif __STDC_VERSION__ >= 201112L
+ #elif __STDC_VERSION__ >= 201112L && defined(__STDC_NO_THREADS__) && __STDC_NO_THREADS__ == 0
#include <threads.h>
#define tlsvar thread_local
#else
