From 92a2e22c6c423c3f8c915a73256fc6bb8aab9cf7 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 6 Sep 2024 12:23:00 +0900 Subject: [PATCH] Restore ASSERT/VERIFY semantics This partly fixes esp32-devkitc:knsh. --- include/assert.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/assert.h b/include/assert.h index 2b13206cfb..d5a8c48872 100644 --- a/include/assert.h +++ b/include/assert.h @@ -118,21 +118,22 @@ * * Reference link: * https://pubs.opengroup.org/onlinepubs/009695399/basedefs/assert.h.html - * - * ASSERT/VERIFY is a non-standard interface, implemented using internal - * */ #ifdef NDEBUG # define assert(f) ((void)0) -# define ASSERT(f) ((void)(1 || (f))) -# define VERIFY(f) ((void)(1 || (f))) #else # define assert(f) _ASSERT(f, __ASSERT_FILE__, __ASSERT_LINE__) -# define ASSERT(f) _ASSERT(f, __ASSERT_FILE__, __ASSERT_LINE__) -# define VERIFY(f) _VERIFY(f, __ASSERT_FILE__, __ASSERT_LINE__) #endif +/* ASSERT/VERIFY are NuttX-specific APIs. + * They are always enabled, regardless of NDEBUG/CONFIG_DEBUG_ASSERTIONS. + * The argument is evaluated exactly once. + */ + +#define ASSERT(f) _ASSERT(f, __ASSERT_FILE__, __ASSERT_LINE__) +#define VERIFY(f) _VERIFY(f, __ASSERT_FILE__, __ASSERT_LINE__) + /* Suppress 3rd party library redefine _assert/__assert */ #define _assert _assert