Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

OSS Library Calls (a - d) assert(3)
NAME
assert - Inserts program diagnostics
LIBRARY
None. This application program interface is implemented as a macro.
SYNOPSIS
#include <assert.h>
void assert (
int expression);
PARAMETERS
expression Specifies an expression that is evaluated as TRUE or FALSE. This expression is
evaluated in the same manner as a C language if control statement.
DESCRIPTION
The assert( ) macro inserts diagnostics into programs. On execution, when the expression
parameter is false (returns FALSE), this macro writes information about the particular call that
failed, including the text of the argument, the stack trace, the name of the source file, and the
source-file line number (the latter two are respectively the values of preprocessing macros
__FILE__and __LINE__)onstderr. The error message is taken from the standard C library
message catalog. It also flushes and closes all files opened for ANSI-model or Alternate-model
I/O and calls the exit function with the parameter EXIT_FAILURE to produce a software abort
fault.
When you compile a program with the -DNDEBUG preprocessor option, or with the #define
NDEBUG preprocessor control statement before the #include <assert.h> statement, calls to the
assert() macro have no effect.
RETURN VALUES
The assert( ) macro returns no value.
RELATED INFORMATION
Functions: abort(3).
STANDARDS CONFORMANCE
The POSIX standards leave some features to the implementing vendor to define. The following
features are affected in the HP implementation:
The stack trace is written to standard error.
All files open for ANSI-model or Alternate-model I/O are flushed and closed.
The exit( ) function is called with the parameter EXIT_FAILURE.
527187-017 Hewlett-Packard Company 133