diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index 2a468c42f..9b5c6d04b 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -1696,20 +1696,32 @@ typedef struct w64wrapper { #define WC_CPP_CAT_(a, b) a ## b #define WC_CPP_CAT(a, b) WC_CPP_CAT_(a, b) - #ifndef static_assert - #if !defined(__cplusplus) && !defined(__STRICT_ANSI__) && \ - !defined(WOLF_C89) && ((defined(__GNUC__) && \ - __GNUC__ >= 5) || defined(__clang__)) - #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) - #define static_assert(expr, ...) \ - __static_assert(expr, ##__VA_ARGS__, #expr) - #elif defined(__STRICT_ANSI__) || defined(WOLF_C89) - #define static_assert(expr) \ - struct WC_CPP_CAT(dummy_struct_, __LINE__) - #else - #define static_assert(...) \ - struct WC_CPP_CAT(wc_dummy_struct_L, __LINE__) + #if defined(__cplusplus) && (__cplusplus >= 201103L) + #ifndef static_assert2 + #define static_assert2 static_assert #endif + #elif !defined(static_assert) + #if !defined(__cplusplus) && \ + !defined(__STRICT_ANSI__) && \ + !defined(WOLF_C89) && \ + defined(__STDC_VERSION__) && \ + (__STDC_VERSION__ >= 201112L) && \ + ((defined(__GNUC__) && \ + (__GNUC__ >= 5)) || \ + defined(__clang__)) + #define static_assert(expr) _Static_assert(expr, #expr) + #ifndef static_assert2 + #define static_assert2(expr, msg) _Static_assert(expr, msg) + #endif + #else + #define static_assert(expr) \ + struct WC_CPP_CAT(wc_dummy_struct_L, __LINE__) + #ifndef static_assert2 + #define static_assert2(expr, msg) static_assert(expr) + #endif + #endif + #elif !defined(static_assert2) + #define static_assert2(expr, msg) static_assert(expr) #endif #ifndef SAVE_VECTOR_REGISTERS