plan9fox/sys/include/ape/assert.h
mischief 034d0b08e9 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.
2018-04-02 21:44:21 -07:00

18 lines
294 B
C

#pragma lib "/$M/lib/ape/libap.a"
#undef assert
#ifdef NDEBUG
#define assert(ignore) ((void)0)
#else
#ifdef __cplusplus
extern "C" {
#endif
extern void _assert(char *, unsigned);
#ifdef __cplusplus
}
#endif
#define assert(e) ((e) ? (void)0 : _assert(__FILE__, __LINE__))
#endif /* NDEBUG */