From 729441fdb6912a0d90cd3cc6400f7326a4ae7358 Mon Sep 17 00:00:00 2001 From: Pieter Willemsen Date: Mon, 26 Feb 2018 12:02:14 +0100 Subject: [PATCH] assert: add static_assert if using c11 --- core/include/assert.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/include/assert.h b/core/include/assert.h index fdb04cc1c7..fe93cde10a 100644 --- a/core/include/assert.h +++ b/core/include/assert.h @@ -109,6 +109,20 @@ NORETURN void _assert_failure(const char *file, unsigned line); #define assert(cond) ((cond) ? (void)0 : core_panic(PANIC_ASSERT_FAIL, assert_crash_message)) #endif +#if !defined __cplusplus +#if __STDC_VERSION__ >= 201112L +/** + * @brief c11 static_assert() macro + */ +#define static_assert(...) _Static_assert(__VA_ARGS__) +#else +/** + * @brief static_assert dummy for c-version < c11 + */ +#define static_assert(...) struct static_assert_dummy +#endif +#endif + #ifdef __cplusplus } #endif