Documentation  |   Table of Contents   |  < Previous   |  Next >   |  Index

6    assert.h

Palm OS® Protein C/C++ Compiler Language & Library Reference

Palm OS® Developer Suite

The <assert.h> header defines the assert() macro, which is used for debugging purposes. It also refers to another macro, NDEBUG, which is defined elsewhere.

Functions and Macros ^TOP^

assert Macro ^TOP^

Purpose

Outputs a diagnostic message to standard errorand stops the program if a test fails.

Prototype

assert (
   condition
)

Parameters

condition
An expression to test; if the result of the expression is false, the diagnostic message is displayed and the program terminates. If the result is true, this macro has no effect.

Example

In the following example, the program will terminate if the data buffer could not be allocated.


char *buffer = malloc(150); 
assert(buffer);