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:
parent
013122b993
commit
034d0b08e9
1 changed files with 1 additions and 1 deletions
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue