diff --git a/include/zephyr/toolchain/gcc.h b/include/zephyr/toolchain/gcc.h index ff00896223d1791..ff46b4df1be4756 100644 --- a/include/zephyr/toolchain/gcc.h +++ b/include/zephyr/toolchain/gcc.h @@ -70,11 +70,14 @@ #define BUILD_ASSERT(EXPR, MSG...) static_assert(EXPR, "" MSG) /* - * GCC 4.6 and higher have the C11 _Static_assert built in, and its + * GCC 4.6 and higher have the C11 _Static_assert built in and its * output is easier to understand than the common BUILD_ASSERT macros. + * Don't use this in C++98 mode though (which we can hit, as + * static_assert() is not available) */ -#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || \ - (__STDC_VERSION__) >= 201100 +#elif !defined(CONFIG_STD_CPP98) && \ + ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || \ + (__STDC_VERSION__) >= 201100) #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG) #else #define BUILD_ASSERT(EXPR, MSG...)