git: 9front

Download patch

ref: a338c0785bfccf8dd7c1b8ac82f41a3b778a0b4b
parent: 12b2c877d55bb8723f428a93028942a9d4729b4b
author: mischief <mischief@offblast.org>
date: Mon Apr 2 17:44:21 EDT 2018

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.

--- a/sys/include/ape/assert.h
+++ b/sys/include/ape/assert.h
@@ -13,5 +13,5 @@
 #ifdef __cplusplus
 }
 #endif
-#define assert(e) {if(!(e))_assert(__FILE__, __LINE__);}
+#define assert(e) ((e) ? (void)0 : _assert(__FILE__, __LINE__))
 #endif /* NDEBUG */
--