From 2ddae23ef3a6a51db07675f3a495a961e3a74d5f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 30 Apr 2021 15:29:51 -0700 Subject: compile_time_macros: Make _STATIC_ASSERT work with C++ BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes Change-Id: Ia17dd2339bb132e72c296bf5062e90b9503d7e2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2864512 Reviewed-by: Daisuke Nojiri --- include/compile_time_macros.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/compile_time_macros.h b/include/compile_time_macros.h index 3844898084..510a71461e 100644 --- a/include/compile_time_macros.h +++ b/include/compile_time_macros.h @@ -13,9 +13,15 @@ #include #endif +#ifdef __cplusplus +#define _STATIC_ASSERT static_assert +#else +#define _STATIC_ASSERT _Static_assert +#endif + /* Test an important condition at compile time, not run time */ #define _BA1_(cond, file, line, msg) \ - _Static_assert(cond, file ":" #line ": " msg) + _STATIC_ASSERT(cond, file ":" #line ": " msg) #define _BA0_(c, f, l, msg) _BA1_(c, f, l, msg) /* Pass in an option message to display after condition */ -- cgit v1.2.1