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.
This commit is contained in:
Paul Backus 2025-02-27 14:15:31 -05:00 committed by GitHub
parent 996acb0528
commit 5fc114165d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -11,3 +11,7 @@ endif
include ../common.mak include ../common.mak
extra_dflags += -d extra_dflags += -d
ifeq ($(OS),windows)
extra_dflags += -P=/std:c11
endif

View file

@ -93,7 +93,7 @@
#if __has_include(<sys/eventfd.h>) #if __has_include(<sys/eventfd.h>)
#include <sys/eventfd.h> #include <sys/eventfd.h>
#endif #endif
#if __has_include(<stdatomic.h>) #if __has_include(<stdatomic.h>) && !defined(__STDC_NO_ATOMICS__)
#include <stdatomic.h> #include <stdatomic.h>
#endif #endif
#if __has_include(<ifaddrs.h>) #if __has_include(<ifaddrs.h>)