From 56a043cbd1a24dfeb9f8a3edd4d91ba868104cc4 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Thu, 13 Jun 2019 15:11:03 +0300 Subject: [PATCH] MBED_STRUCT_STATIC_ASSERT: Use standard C++11/C11 If available, we can use standard static_assert. --- platform/mbed_assert.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/platform/mbed_assert.h b/platform/mbed_assert.h index a9bbc8c696..7b2be2cfaa 100644 --- a/platform/mbed_assert.h +++ b/platform/mbed_assert.h @@ -24,7 +24,6 @@ #ifndef MBED_ASSERT_H #define MBED_ASSERT_H -#include #include "mbed_preprocessor.h" #include "mbed_toolchain.h" @@ -125,8 +124,14 @@ do { \ * }; * @endcode */ +#if defined(__cplusplus) && (__cplusplus >= 201103L || __cpp_static_assert >= 200410L) +#define MBED_STRUCT_STATIC_ASSERT(expr, msg) static_assert(expr, msg) +#elif !defined(__cplusplus) && __STDC_VERSION__ >= 201112L +#define MBED_STRUCT_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg) +#else +#include #define MBED_STRUCT_STATIC_ASSERT(expr, msg) bool : (expr) ? 0 : -1 - +#endif #endif