[clang] bbc690c - Define __STDC_NO_THREADS__ when targeting windows-msvc (PR48704)
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 16 07:30:19 PST 2021
Author: Hans Wennborg
Date: 2021-12-16T16:30:06+01:00
New Revision: bbc690c57213054907284d8964dc0487d38fc57a
URL: https://github.com/llvm/llvm-project/commit/bbc690c57213054907284d8964dc0487d38fc57a
DIFF: https://github.com/llvm/llvm-project/commit/bbc690c57213054907284d8964dc0487d38fc57a.diff
LOG: Define __STDC_NO_THREADS__ when targeting windows-msvc (PR48704)
MSVC's libc doesn't provide thread.h, so we should set the macro to
indicate that.
We could just set it in C mode, but I noticed that Darwin sets it
unconditionally, so perhaps we should do the same here.
Differential revision: https://reviews.llvm.org/D112081
Added:
Modified:
clang/lib/Basic/Targets/OSTargets.cpp
clang/test/Preprocessor/init.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/OSTargets.cpp b/clang/lib/Basic/Targets/OSTargets.cpp
index 695cbafe36557..f8f12daaa0722 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -203,6 +203,7 @@ static void addVisualCDefines(const LangOptions &Opts, MacroBuilder &Builder) {
}
Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
+ Builder.defineMacro("__STDC_NO_THREADS__");
// Starting with VS 2022 17.1, MSVC predefines the below macro to inform
// users of the execution character set defined at compile time.
diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 52c33d9b8b7a5..7d838413b8513 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -195,6 +195,7 @@
// MSEXT-NOT:#define _NATIVE_WCHAR_T_DEFINED 1
// MSEXT-NOT:#define _WCHAR_T_DEFINED 1
// MSEXT:#define _MSVC_EXECUTION_CHARACTER_SET 65001
+// MSEXT:#define __STDC_NO_THREADS__ 1
//
//
// RUN: %clang_cc1 -x c++ -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix MSEXT-CXX %s
More information about the cfe-commits
mailing list