wolfssl/wolfcrypt/types.h: dial in the __static_assert() gating+definitions, and add static_assert2().

This commit is contained in:
Daniel Pouzzner
2024-09-19 13:10:47 -05:00
parent fbbb2b876b
commit 510d6a07bf

View File

@ -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