From d4247befa18a7911c56e7110154ad73574cd6648 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 15 Nov 2024 11:57:18 -0300 Subject: [PATCH] New macro 'assert_code' It allows code that is only used by assertions but that are not assertions (e.g., declaration of a variable used in a later assertion). --- llimits.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/llimits.h b/llimits.h index f189048c..6cf35e0c 100644 --- a/llimits.h +++ b/llimits.h @@ -102,18 +102,19 @@ typedef LUAI_UACINT l_uacInt; #undef NDEBUG #include #define lua_assert(c) assert(c) +#define assert_code(c) c #endif #if defined(lua_assert) -#define check_exp(c,e) (lua_assert(c), (e)) -/* to avoid problems with conditions too long */ -#define lua_longassert(c) ((c) ? (void)0 : lua_assert(0)) #else #define lua_assert(c) ((void)0) -#define check_exp(c,e) (e) -#define lua_longassert(c) ((void)0) +#define assert_code(c) ((void)0) #endif +#define check_exp(c,e) (lua_assert(c), (e)) +/* to avoid problems with conditions too long */ +#define lua_longassert(c) assert_code((c) ? (void)0 : lua_assert(0)) + /* macro to avoid warnings about unused variables */ #if !defined(UNUSED)