atexit

assert

#include <assert.h>void assert(int exp);

The assert( ) macro, defined in the headers <assert.h> and <cassert>, writes error information to stderr and then aborts program execution if the expression exp evaluates to zero. Otherwise, assert( ) does nothing. Although the exact output is implementation defined, many compilers use a message similar to this:

Assertion failed: <expression>, file <file>, line <linenum>

For C99, the message will also include the name of the function that contained assert( ).

The assert( ) macro is generally used to help verify that a program is operating correctly, with the expression being devised in such a way that it evaluates to true only when no errors have taken place.

It is not necessary to remove the assert( ) statements from the source code once a program is debugged because if the macro NDEBUG is defined (as anything), the assert( ) macros will be ignored.

A related function is abort( ).




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net