mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
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
1 changed files with 4 additions and 3 deletions
|
@ -41,12 +41,13 @@ safe_isnan(double a) {
|
|||
assert(false); \
|
||||
abort(); \
|
||||
} while (0)
|
||||
#define CHECK_EXPR(...) ((void)0)
|
||||
/// Same as assert, but evaluates the expression even in release builds
|
||||
#define CHECK(expr) \
|
||||
do { \
|
||||
__auto_type __tmp = (expr); \
|
||||
assert(__tmp); \
|
||||
(void)__tmp; \
|
||||
__auto_type _ = (expr); \
|
||||
assert((CHECK_EXPR(expr), _)); \
|
||||
(void)_; \
|
||||
} while (0)
|
||||
|
||||
// Some macros for checked cast
|
||||
|
|
Loading…
Reference in a new issue