summaryrefslogtreecommitdiff
path: root/include/compile_time_macros.h
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2021-04-30 15:29:51 -0700
committerCommit Bot <commit-bot@chromium.org>2021-05-03 21:40:11 +0000
commit2ddae23ef3a6a51db07675f3a495a961e3a74d5f (patch)
treed0c43e6df928a44a396251d75ca7a194137113de /include/compile_time_macros.h
parent200fd26fb76712ba8be104f767095e3488a99263 (diff)
downloadchrome-ec-2ddae23ef3a6a51db07675f3a495a961e3a74d5f.tar.gz
compile_time_macros: Make _STATIC_ASSERT work with C++
BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ia17dd2339bb132e72c296bf5062e90b9503d7e2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2864512 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include/compile_time_macros.h')
-rw-r--r--include/compile_time_macros.h8
1 files changed, 7 insertions, 1 deletions
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 <sys/util.h>
#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 */