utils: improve CHECK() macro
Include the original expression in the assertion failure message. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
0733f7540f
commit
2040190fb6
|
@ -41,12 +41,13 @@ safe_isnan(double a) {
|
||||||
assert(false); \
|
assert(false); \
|
||||||
abort(); \
|
abort(); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#define CHECK_EXPR(...) ((void)0)
|
||||||
/// Same as assert, but evaluates the expression even in release builds
|
/// Same as assert, but evaluates the expression even in release builds
|
||||||
#define CHECK(expr) \
|
#define CHECK(expr) \
|
||||||
do { \
|
do { \
|
||||||
__auto_type __tmp = (expr); \
|
__auto_type _ = (expr); \
|
||||||
assert(__tmp); \
|
assert((CHECK_EXPR(expr), _)); \
|
||||||
(void)__tmp; \
|
(void)_; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
// Some macros for checked cast
|
// Some macros for checked cast
|
||||||
|
|
Loading…
Reference in New Issue