HP 3000 Manuals

assert [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation


HP C/iX Library Reference Manual

assert 

Terminates the program if the assertion is false.

Syntax 

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

Parameters 

expression    An integer value to be evaluated.

Return Values 

None.

Description 

The assert macro terminates the program if the assertion is false.  The
assert macro takes a single integer (expression) argument.  If the
expression evaluates to 0 (false), assert() writes a message containing
the expression that tested false and the line number where the assert
occurred.  The program then terminates.  The macro NDEBUG is referenced
but not defined in <assert.h>.  If NDEBUG is defined at the point when
<assert.h> is included, the assert macro calls have no effect.  The
NDEBUG macro enables the operation of the assert macro:

--------------------------------------------------------------------------------------------
|                                    |                                                     |
| NDEBUG Definition                  | assert macro effect                                 |
|                                    |                                                     |
--------------------------------------------------------------------------------------------
|                                    |                                                     |
| Defined                            | Calls are ignored (no debugging done)               |
|                                    |                                                     |
| Undefined                          | Calls are processed (debugging is done)             |
|                                    |                                                     |
--------------------------------------------------------------------------------------------

See Also 

abort(), ANSI C 4.2.1.1, POSIX.1 8.1



MPE/iX 5.0 Documentation