================
@@ -248,8 +248,19 @@ static void addVisualCDefines(const LangOptions &Opts, 
MacroBuilder &Builder) {
     Builder.defineMacro("_KERNEL_MODE");
 
   Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
-  Builder.defineMacro("__STDC_NO_THREADS__");
-
+  // Define __STDC_NO_THREADS__ based on MSVC version, threads.h availability,
+  // and language standard.
+  if (!Opts.isCompatibleWithMSVC(LangOptions::MSVC2022_9)) {
+    Builder.defineMacro("__STDC_NO_THREADS__");
+  } else {
+#if defined(__has_include) && !__has_include(<threads.h>)
+    Builder.defineMacro("__STDC_NO_THREADS__");
+#endif
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ < 201112L
+    Builder.defineMacro("__STDC_NO_THREADS__");
+#endif
----------------
AaronBallman wrote:

These changes are looking at the host compiler's behavior when building Clang, 
not the state of the system on which Clang is running, so they won't do what 
you expect.

Trying to determine if the system has a threads.h header on the search path is 
possible, but would be really tricky to do from here because this function 
doesn't have access to what's needed to do that work.

As for checking for C11, that can be done via `!Opts.C11`

https://github.com/llvm/llvm-project/pull/117149
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to