updated package versions
[minix.git] / include / assert.h
blob13f3422dd9fe306a8016d48b043e457f3ba67da4
1 /* The <assert.h> header contains a macro called "assert" that allows
2 * programmers to put assertions in the code. These assertions can be verified
3 * at run time. If an assertion fails, an error message is printed and the
4 * program aborts.
5 * Assertion checking can be disabled by adding the statement
7 * #define NDEBUG
9 * to the program before the
11 * #include <assert.h>
13 * statement.
16 #undef assert
18 #ifndef _ANSI_H
19 #include <ansi.h>
20 #endif
22 #ifdef NDEBUG
23 /* Debugging disabled -- do not evaluate assertions. */
24 #define assert(expr) ((void) 0)
25 #else
26 /* Debugging enabled -- verify assertions at run time. */
27 #ifdef _ANSI
28 #define __makestr(x) # x
29 #define __xstr(x) __makestr(x)
31 _PROTOTYPE( void __bad_assertion, (const char *_mess) );
32 #define assert(expr) ((expr)? (void)0 : \
33 __bad_assertion("Assertion \"" #expr \
34 "\" failed, file " __xstr(__FILE__) \
35 ", line " __xstr(__LINE__) "\n"))
36 #else
37 #define assert(expr) ((void) ((expr) ? 0 : __assert( __FILE__, __LINE__)))
38 #endif /* _ANSI */
39 #endif