Assert routine for debugging purposes
void assert (short condition); |
Tests a condition and possibly aborts.
assert is a macro for debugging purposes that expands to an if statement.
If condition evaluates to zero, assert opens an error message box, waits for
a keypress, then abort the program. Here is a HTMLized "picture" which shows principally
how such message box looks like:
| |
Condition: condition_written_as_text File: filename Line: linenum
|
#define NDEBUG
("no debugging") in the source code before the
#include <assert.h>
directive, the assert statement will be ignored.
It might be hard to use this function if you are compiling your program with the IDE
(it is possible to get wrong line numbers). In any case, turning off file splitting may be useful.