Fix assert when used as an expression

Based on what musl does.
This commit is contained in:
Tibor Nagy
2018-10-27 17:40:24 +02:00
parent bfa068df88
commit e7f251fdb0
3 changed files with 8 additions and 5 deletions
+3 -4
View File
@@ -2,11 +2,10 @@
#define _BITS_ASSERT_H
#ifdef NDEBUG
# define assert(cond)
# define assert(cond) (void) 0
#else
# define assert(cond) if (!(cond)) { \
__assert(__func__, __FILE__, __LINE__, #cond); \
}
# define assert(cond) \
((void)((cond) || (__assert(__func__, __FILE__, __LINE__, #cond), 0)))
#endif
#endif