[debug] check NDEBUG for OT_ASSERT (#11929)

This commit verifies NDEBUG is not defined when OT_ASSERT is enabled and
is delegated to assert().
This commit is contained in:
Yakun Xu
2025-09-19 17:52:38 -07:00
committed by GitHub
parent da61dc7eba
commit 466fdb87fa
2 changed files with 9 additions and 0 deletions
+5
View File
@@ -69,6 +69,11 @@
#elif defined(__APPLE__) || defined(__linux__)
#ifdef NDEBUG
#error \
"OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT is not defined, OT_ASSERT requires assert() to work, but NDEBUG is defined!"
#endif
#include <assert.h>
#define OT_ASSERT(cond) assert(cond)
+4
View File
@@ -335,7 +335,11 @@
* Define as 1 to enable assert function `OT_ASSERT()` within OpenThread code and its libraries.
*/
#ifndef OPENTHREAD_CONFIG_ASSERT_ENABLE
#ifndef NDEBUG
#define OPENTHREAD_CONFIG_ASSERT_ENABLE 1
#else
#define OPENTHREAD_CONFIG_ASSERT_ENABLE 0
#endif
#endif
/**