diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-11-15 11:57:18 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-11-15 11:57:18 -0300 |
commit | d4247befa18a7911c56e7110154ad73574cd6648 (patch) | |
tree | 065e60201d94f068c7b808dd0ab9b8f4464336ea | |
parent | ee6a4cd1eca4fa736d108e1e0ac3cb9858f7a5ef (diff) | |
download | lua-d4247befa18a7911c56e7110154ad73574cd6648.tar.gz lua-d4247befa18a7911c56e7110154ad73574cd6648.tar.bz2 lua-d4247befa18a7911c56e7110154ad73574cd6648.zip |
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).
-rw-r--r-- | llimits.h | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -102,18 +102,19 @@ typedef LUAI_UACINT l_uacInt; | |||
102 | #undef NDEBUG | 102 | #undef NDEBUG |
103 | #include <assert.h> | 103 | #include <assert.h> |
104 | #define lua_assert(c) assert(c) | 104 | #define lua_assert(c) assert(c) |
105 | #define assert_code(c) c | ||
105 | #endif | 106 | #endif |
106 | 107 | ||
107 | #if defined(lua_assert) | 108 | #if defined(lua_assert) |
108 | #define check_exp(c,e) (lua_assert(c), (e)) | ||
109 | /* to avoid problems with conditions too long */ | ||
110 | #define lua_longassert(c) ((c) ? (void)0 : lua_assert(0)) | ||
111 | #else | 109 | #else |
112 | #define lua_assert(c) ((void)0) | 110 | #define lua_assert(c) ((void)0) |
113 | #define check_exp(c,e) (e) | 111 | #define assert_code(c) ((void)0) |
114 | #define lua_longassert(c) ((void)0) | ||
115 | #endif | 112 | #endif |
116 | 113 | ||
114 | #define check_exp(c,e) (lua_assert(c), (e)) | ||
115 | /* to avoid problems with conditions too long */ | ||
116 | #define lua_longassert(c) assert_code((c) ? (void)0 : lua_assert(0)) | ||
117 | |||
117 | 118 | ||
118 | /* macro to avoid warnings about unused variables */ | 119 | /* macro to avoid warnings about unused variables */ |
119 | #if !defined(UNUSED) | 120 | #if !defined(UNUSED) |