1 #include <features.h> 2 3 #undef assert 4 5 6 /** 7 * @ingroup assert 8 * @par Description: 9 * This API is used to insert diagnostics into programs, if expression is false, it will output the text of the argument, 10 * the name of the source file, the source file line number, and the name of the enclosing function 11 * 12 * @attention 13 * <ul> 14 * <li>The assert() macro only prints an error message, it would not call abort,instead by locking the interrupt and entering dead cycle by doing while (1).</li> 15 * </ul> 16 * 17 * @retval None. 18 * 19 * @par Dependency: 20 * <ul><li>assert.h</li></ul> 21 * 22 * @see None 23 * 24 */ 25 #ifdef NDEBUG 26 #define assert(x) (void)0 27 #else 28 #define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0))) 29 #endif 30 31 #ifdef __LITEOS__ 32 #ifdef CONFIG_DEBUG 33 #define DEBUGASSERT(f) ((void)((f) || (__assert_fail(#f, __FILE__, __LINE__, __func__),0))) 34 #else 35 #define DEBUGASSERT(f) 36 #endif 37 #endif 38 39 #if __STDC_VERSION__ >= 201112L && !defined(__cplusplus) 40 #define static_assert _Static_assert 41 #endif 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 _Noreturn void __assert_fail (const char *, const char *, int, const char *); 48 49 #ifdef __cplusplus 50 } 51 #endif 52