1 /* 2 * 3 * assert.h 4 * 5 * Assertion - use liberally for debugging. Defining NDEBUG 6 * turns assertions off. 7 * assert(exp) where exp is non-zero does nothing, while 8 * assert(exp) where exp evaluates to zero aborts the program 9 * with a message like 10 * 11 * Assertion failed: prog.c line 123: "exp" 12 * 13 * djm 28/2/2000 14 * 15 * $Id: assert.h,v 1.5 2016-06-11 19:53:08 dom Exp $ 16 * 17 */ 18 19 #ifndef __ASSERT_H__ 20 #define __ASSERT_H__ 21 22 #include <sys/compiler.h> 23 24 #ifndef NDEBUG 25 extern void __LIB__ l_assert(int line, const char *file, const char *msg) __smallc; 26 #define assert(exp) if((exp==0)) {l_assert(__LINE__, __FILE__, #exp );} 27 #else 28 #define assert(exp) 29 #endif /* NDEBUG */ 30 31 #endif /* _ASSERT_H */ 32 33