MBED_STRUCT_STATIC_ASSERT: Use standard C++11/C11

If available, we can use standard static_assert.
pull/10837/head
Kevin Bracey 2019-06-13 15:11:03 +03:00
parent 700410049c
commit 56a043cbd1
1 changed files with 7 additions and 2 deletions

View File

@ -24,7 +24,6 @@
#ifndef MBED_ASSERT_H
#define MBED_ASSERT_H
#include <stdbool.h>
#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 <stdbool.h>
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) bool : (expr) ? 0 : -1
#endif
#endif