ASSERT(3X) SysV ASSERT(3X)
NAME
assert - verify program assertion
SYNOPSIS
#include <assert.h>
void assert(expression)
int expression;
DESCRIPTION
This macro is useful for putting diagnostics into programs. assert
indicates that expression is expected to be true (non-zero) at this point
in the program. It causes an abort(3C) with a diagnostic comment on the
standard error output when expression is false (0). The diagnostic
comment includes the text of expression, the source file name, and the
source line number.
If the name NDEBUG is defined previous to including assert.h, either by
compiling with the cc(1) option -DNDEBUG or using the #define
preprocessor directive, assert calls are effectively deleted from the
program [assert is defined to evaluate to (void(0))].
NOTES
If _CLASSIC_ASSERT is defined, assert.h will declare the _assert
function, rather than __assert function (and assert will evaluate to an
_assert call). This violates ANSI C requirements for application
reserved names, but provides compatibility with typical common C library
naming. There are no semantic differences; _assert is a wrapper for
__assert.
Defining _CLASSIC_TYPES causes _CLASSIC_ASSERT to be defined.
DIAGNOSTICS
"Assertion failed: file f line n." f is the source file and n the source
line number of the assert statement.
SEE ALSO
cpp(1), abort(3C).
CAVEAT
Since assert is implemented as a macro, the expression may not contain
any string literals.