Guardian C Library Calls Reference Manual
assert
3-6 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
assert
The assert macro enables you to insert run-time diagnostics, or assertions, into your
program. After developing and debugging your program, you can disable the assertions
by defining the identifier NDEBUG as a preprocessor symbol before including the
asserth header.
expr
determines whether an invocation of assert generates a diagnostic message and
terminates the program. If expr evaluates to a nonzero value, assert does nothing and
program execution continues. If expr evaluates to zero, assert writes a diagnostic
message and stack trace to stderr, flushes and closes all files opened for ANSI or
alternate I/O, and calls the system procedure PROCESS_STOP_ with the ABEND
option.
Return Value
none.
Usage Guidelines
•
The diagnostic message produced by assert includes the text of expr, the name of the
source file, and the source line number.
•
The expression you use as expr should not contain side effects, as these effects will
not occur if NDEBUG is defined.
•
To disable all assertions, you must ensure that NDEBUG is defined as a macro name
when asserth is included.
#include <asserth>
void assert(int expr);