1 /* 2 ** Distributed under the terms of the Haiku License. 3 */ 4 #ifndef _ASSERT_H_ 5 #define _ASSERT_H_ 6 7 #undef assert 8 9 #ifndef NDEBUG 10 // defining NDEBUG disables assert() functionality 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 extern void __assert_fail(const char *assertion, const char *file, 17 unsigned int line, const char *function); 18 19 extern void __assert_perror_fail(int error, const char *file, 20 unsigned int line, const char *function); 21 22 #ifdef __cplusplus 23 } 24 #endif 25 26 #define assert(assertion) \ 27 ((assertion) ? (void)0 : __assert_fail(#assertion, __FILE__, __LINE__, __PRETTY_FUNCTION__)) 28 29 #else // NDEBUG 30 # define assert(condition) ; 31 #endif 32 33 #endif /* _ASSERT_H_ */ 34