mirror of
https://github.com/lua/lua
synced 2024-11-25 22:29:39 +03:00
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).
This commit is contained in:
parent
ee6a4cd1ec
commit
d4247befa1
11
llimits.h
11
llimits.h
@ -102,18 +102,19 @@ typedef LUAI_UACINT l_uacInt;
|
|||||||
#undef NDEBUG
|
#undef NDEBUG
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#define lua_assert(c) assert(c)
|
#define lua_assert(c) assert(c)
|
||||||
|
#define assert_code(c) c
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(lua_assert)
|
#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
|
#else
|
||||||
#define lua_assert(c) ((void)0)
|
#define lua_assert(c) ((void)0)
|
||||||
#define check_exp(c,e) (e)
|
#define assert_code(c) ((void)0)
|
||||||
#define lua_longassert(c) ((void)0)
|
|
||||||
#endif
|
#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 */
|
/* macro to avoid warnings about unused variables */
|
||||||
#if !defined(UNUSED)
|
#if !defined(UNUSED)
|
||||||
|
Loading…
Reference in New Issue
Block a user