assert() Macro assert() Check assertion at run time #include <assert.h> void assert(expression) int expression; assert checks the value of expression. If expression is false (zero), assert sends a message into the standard-error stream and calls exit. It is useful for verifying that a necessary con- dition is true. The error message includes the text of the assertion that failed, the name of the source file, and the line within the source file that holds the expression in question. These last two elements consist, respectively, of the values of the preprocessor macros _ _FILE_ _ and _ _LINE_ _. assert calls exit, which never returns. To turn off assert, define the macro NDEBUG prior to including the header assert.h. This forces assert to be redefined as #define assert(ignore) ***** See Also ***** exit(), assert.h, C preprocessor ***** Notes ***** The Standard requires that assert be implemented as a macro, not a library function. If a program suppresses the macro definition in favor of a function call, its behavior is undefined. Turning off assert with the macro NDEBUG will affect the behavior of a program if the expression being evaluated normally generates side effects. assert is useful for debugging, and for testing boundary con- ditions for which more graceful error recovery has not yet been implemented. COHERENT Lexicon Page 1