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.
This commit is contained in:
mischief 2018-04-02 21:44:21 -07:00
parent 013122b993
commit 034d0b08e9

View file

@ -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 */