ASSERT(S) UNIX System V ASSERT(S)
Name
assert - verify program assertion
Syntax
#include <assert.h>
assert (expression)
int expression;
Description
This macro is useful for putting diagnostics into programs.
When it is executed, if expression is false (zero), assert
prints
``Assertion failed: expression, file xyz, line nnn''
on the standard error output and aborts. In the error
message, xyz is the name of the source file and nnn the
source line number of the assert statement.
Compiling with the preprocessor option -DNDEBUG (see
cpp(CP)), or with the preprocessor control statement
``#define NDEBUG'' ahead of the ``#include <assert.h>''
statement, will stop assertions from being compiled into the
program.
See Also
cpp(CP), abort(S).
Notes
Since assert is implemented as a macro, the expression may
not contain any string literals.
Standards Conformance
assert is conformant with:
AT&T SVID Issue 2, Select Code 307-127;
The X/Open Portability Guide II of January 1987;
and ANSI X3.159-198X C Language Draft Standard, May 13,
1988.
(printed 6/20/89)