diff options
author | mischief <mischief@offblast.org> | 2018-04-02 21:44:21 -0700 |
---|---|---|
committer | mischief <mischief@offblast.org> | 2018-04-02 21:44:21 -0700 |
commit | 034d0b08e91ee11278875168176954bb4572c76e (patch) | |
tree | b147c39a1f36e9bd0d29400bd742818e4c9067c4 /sys/include | |
parent | 013122b993652f0b76af026a15219e103ed94468 (diff) |
ape: improve assert macro
in a statement such as:
if(expr)
assert(a);
else
assert(b);
the previous definition of assert would fail to compile, as the else
would be dangling. with a ternary expression, this construct works
fine.
Diffstat (limited to 'sys/include')
-rw-r--r-- | sys/include/ape/assert.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/include/ape/assert.h b/sys/include/ape/assert.h index 40c26102c..89e9b6b67 100644 --- a/sys/include/ape/assert.h +++ b/sys/include/ape/assert.h @@ -13,5 +13,5 @@ extern void _assert(char *, unsigned); #ifdef __cplusplus } #endif -#define assert(e) {if(!(e))_assert(__FILE__, __LINE__);} +#define assert(e) ((e) ? (void)0 : _assert(__FILE__, __LINE__)) #endif /* NDEBUG */ |