@ -123,8 +123,8 @@ Build Assertions
@@ -123,8 +123,8 @@ Build Assertions
Zephyr provides two macros for performing build-time assertion checks.
These are evaluated completely at compile-time, and are always checked.
BUILD_ASSERT_MSG ()
------------------
BUILD_ASSERT()
--------------
This has the same semantics as C's `` _Static_assert `` or C++'s
`` static_assert `` . If the evaluation fails, a build error will be generated by
@ -138,8 +138,7 @@ For example, suppose this check fails:
@@ -138,8 +138,7 @@ For example, suppose this check fails:
.. code-block :: c
BUILD_ASSERT_MSG(FOO == 2000,
"Invalid value of FOO");
BUILD_ASSERT(FOO == 2000, "Invalid value of FOO");
With GCC, the output resembles:
@ -147,17 +146,16 @@ With GCC, the output resembles:
@@ -147,17 +146,16 @@ With GCC, the output resembles:
tests/kernel/fatal/src/main.c: In function 'test_main':
include/toolchain/gcc.h:28:37: error: static assertion failed: "Invalid value of FOO"
#define BUILD_ASSERT_MSG (EXPR, MSG) _Static_assert(EXPR, MSG)
^~~~~~~~~~~~~~
tests/kernel/fatal/src/main.c:370:2: note: in expansion of macro 'BUILD_ASSERT_MSG '
BUILD_ASSERT_MSG (FOO == 2000,
#define BUILD_ASSERT(EXPR, MSG) _Static_assert(EXPR, "" MSG)
^~~~~~~~~~~~~~
tests/kernel/fatal/src/main.c:370:2: note: in expansion of macro 'BUILD_ASSERT'
BUILD_ASSERT(FOO == 2000,
^~~~~~~~~~~~~~~~
BUILD_ASSERT()
--------------
BUILD_ASSERT_MSG ()
------------------
This works just like `` BUILD_ASSERT_MSG() `` except there is no supplemental
message provided, and like `` __ASSERT_NO_MSG() `` its use is discouraged.
This macro is identical to `` BUILD_ASSERT() `` . Its use is deprecated.
Kernel Oops
===========