diff --git a/src/core/common/debug.hpp b/src/core/common/debug.hpp index de159559f..974b0f0e1 100644 --- a/src/core/common/debug.hpp +++ b/src/core/common/debug.hpp @@ -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 #define OT_ASSERT(cond) assert(cond) diff --git a/src/core/config/misc.h b/src/core/config/misc.h index ea50a0801..8b1af2858 100644 --- a/src/core/config/misc.h +++ b/src/core/config/misc.h @@ -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 /**