From 034d0b08e91ee11278875168176954bb4572c76e Mon Sep 17 00:00:00 2001 From: mischief Date: Mon, 2 Apr 2018 21:44:21 -0700 Subject: [PATCH] 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. --- sys/include/ape/assert.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */