From 5fc114165d51c2974d08100a7338bb4ed7ab87c4 Mon Sep 17 00:00:00 2001 From: Paul Backus Date: Thu, 27 Feb 2025 14:15:31 -0500 Subject: [PATCH] Fix importc_compare test on Windows (#20922) MSVC does not support C11 atomics, but it still provides a "stub" version of stdatomic.h, which aborts compilation with an #error directive when included. To avoid this error, explicitly set the C standard to C11 when invoking the C preprocessor on Windows, and check for the C11 macro __STDC_NO_ATOMICS__ before including stdatomic.h. --- druntime/test/importc_compare/Makefile | 4 ++++ druntime/test/importc_compare/src/importc_includes.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/druntime/test/importc_compare/Makefile b/druntime/test/importc_compare/Makefile index 47af3d8115..957ac9f212 100644 --- a/druntime/test/importc_compare/Makefile +++ b/druntime/test/importc_compare/Makefile @@ -11,3 +11,7 @@ endif include ../common.mak extra_dflags += -d + +ifeq ($(OS),windows) + extra_dflags += -P=/std:c11 +endif diff --git a/druntime/test/importc_compare/src/importc_includes.c b/druntime/test/importc_compare/src/importc_includes.c index 421ad42e46..a385743bca 100644 --- a/druntime/test/importc_compare/src/importc_includes.c +++ b/druntime/test/importc_compare/src/importc_includes.c @@ -93,7 +93,7 @@ #if __has_include() #include #endif -#if __has_include() +#if __has_include() && !defined(__STDC_NO_ATOMICS__) #include #endif #if __has_include()