From 52bef353e0e424a360d385e1ff43c63ed98009c3 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Wed, 30 Dec 2020 19:03:10 +0100 Subject: [PATCH] Workaround WIN clang that claims to be C11 but fails to deliver a working assert.h (See #85) --- m-core.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/m-core.h b/m-core.h index f28587ee..746f14bc 100644 --- a/m-core.h +++ b/m-core.h @@ -327,8 +327,10 @@ M_BEGIN_PROTECTED_CODE Quite usefull to terminate with a proper error message rather than a garbage of error due to incorrect code generation in the methods expansion. + NOTE: Some implementation claims to be C11 (default mode) but fails + to deliver a working assert.h with static_assert. */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && defined(static_assert)) || defined(__cplusplus) # define M_STATIC_FAILURE(error, msg) static_assert(false, #error ": " msg); #else # define M_STATIC_FAILURE(error, msg) struct error { int error : 0;}; @@ -347,7 +349,7 @@ M_BEGIN_PROTECTED_CODE #if defined(__cplusplus) # define M_STATIC_ASSERT(cond, error, msg) \ ([] { static_assert(cond, #error ": " msg); } ()) -#elif defined(__GNUC__) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#elif defined(__GNUC__) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && defined(static_assert) # define M_STATIC_ASSERT(cond, error, msg) \ M_ATTR_EXTENSION ({ static_assert(cond, #error ": " msg); }) #else