[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
threads-h: Don't override the C++ keyword 'thread_local'
From: |
Bruno Haible |
Subject: |
threads-h: Don't override the C++ keyword 'thread_local' |
Date: |
Wed, 28 Aug 2024 17:12:04 +0200 |
clang on native Windows produces the warning:
In file included from
C:\cygwin64\home\bruno\testdir-all-for-msvc\gltests\test-threads-c++.cc:22:
../gllib\threads.h(685,10): warning: keyword is hidden by macro definition
[-Wkeyword-macro]
The cause is that in C++ 11 or newer, 'thread_local' is a keyword, and
there is no need to redefine it as a macro.
This patch fixes it.
2024-08-28 Bruno Haible <bruno@clisp.org>
threads-h: Don't override the C++ keyword 'thread_local'.
* lib/threads.in.h (thread_local): Don't define as a macro in C++ 11
or newer.
diff --git a/lib/threads.in.h b/lib/threads.in.h
index 4e21fc7628..6a52e7b795 100644
--- a/lib/threads.in.h
+++ b/lib/threads.in.h
@@ -97,7 +97,9 @@
its expansion ends in a semicolon. */
# undef thread_local
#endif
-#if !@HAVE_THREADS_H@ || !defined thread_local
+#if (!@HAVE_THREADS_H@ || !defined thread_local) \
+ && !(defined __cplusplus \
+ && (__cplusplus >= 201103L || (defined _MSC_VER && _MSC_VER >= 1900)))
# define thread_local _Thread_local
#endif
/* Define the macro thread_local if and only if it actually works. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- threads-h: Don't override the C++ keyword 'thread_local',
Bruno Haible <=