ASSERT - program verification.

(ANSI Standard)

Usage:

#include <assert.h>
assert( expression );

Description:

"assert" is a macro that determines whether the given expression is TRUE (i.e. non-zero). If the expression is TRUE, "assert" takes no action. If the expression is FALSE (i.e. zero), it prints a message of the form

Assertion "expression" failed, file xxx, line yyy

(where "xxx" and "yyy" are of course the source file and the line number containing the "assert" macro). Once the message has been printed out, "assert" will terminate program execution via "abort".

"assert" is intended for debugging purposes, to check for conditions that ought not to happen. Once you have debugged your program, you may use #define to define a manifest called NDEBUG, e.g.

#define NDEBUG 1

This will turn all the calls to "assert" into null macros, effectively removing them from your source code. In this way, you streamline the machine code produced for your program without having to remove your assertions physically.

Copyright © 1996, Thinkage Ltd.