The <assert.h> header file


  
This header file contains the following functions:
assert

Functions


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.

NOTE: The problem with "assert" in "nostub" mode (described in previous releases of TIGCCLIB) is solved in release 2.0 of the TIGCCLIB, so there is no more any problems with assert function.

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.

Return to the main index