From 4642e0b5065bc2d2417843e8bba5729dcfa5c03f Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 5 Jan 2019 00:19:09 +0100 Subject: [PATCH] Workaround issue of stdatomic on MSYS2/GCC --- m-atomic.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/m-atomic.h b/m-atomic.h index 749eed99..592014cd 100644 --- a/m-atomic.h +++ b/m-atomic.h @@ -106,6 +106,18 @@ using std::memory_order_seq_cst; and doesn't provide its own stdatomic.h */ #include +/* MSYS2 has a conflict between cdefs.h which defines a _Atomic macro (if not C11) + not compatible with the used stdatomic.h (from GCC). + Provide a configurable mechanism to undef it with auto-detection of msys2 / gcc */ +#ifndef M_USE_UNDEF_ATOMIC +# if defined(__MSYS__) && defined(__GNUC__) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L) +# define M_USE_UNDEF_ATOMIC 1 +# endif +#endif +#if defined(M_USE_UNDEF_ATOMIC) && M_USE_UNDEF_ATOMIC == 1 +# undef _Atomic +#endif + #else /* Non working atomic.h, nor working stdatomic.h found.