[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
assert() Diagnostic Message Generator
#include <assert.h>
void assert(expression); Call removed if NDEBUG is defined.
int expression;
assert() tests 'expression'. If 'expression' fails, assert() prints a
diagnostic message and aborts the calling process. 'expression'
should be chosen so it is true if the program is operating correctly.
No action is taken if 'expression' is true (nonzero).
The diagnostic message has the form:
Assertion failed: file 'filename', line 'linenumber'
where 'filename' is the source file name and 'linenumber' is the line
number where assert() appears. assert() is used to identify program
logic errors.
Returns: There is no return value.
Notes: assert() is a macro.
If NDEBUG is defined (with any value), the C preprocessor
removes all assert() calls from the program. NDEBUG can
be defined with the /D command-line option, or with a
#define directive.
-------------------------------- Example ---------------------------------
The following statement tests whether pshift is NULL and prints an
appropriate message.
#include <assert.h>
#include <stdio.h>
struct BASE {
char *name;
int number;
} *pshift;
main()
{
assert(pshift != NULL);
/* process item */
}
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson