| assert | Function (Macro)

assert.h

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:

ASSERTION FAILED
Condition: condition_written_as_text File: filename Line: linenum
Enter=OK

The filename and linenum listed in the message box are the source file name and line number where the assert macro appears. assert expands to relatively big code, so if you have many assert statements in the program, it may become quite long relatively fast. But, if you place the directive

    #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.

Uses: ScrRect, ngetchx, DrawStaticButton, MakeWinRect, WinClose, WinFont, WinOpen, WinStr, sprintf