7.4.2 <assert.h>

Adds diagnostics into programs.

Type

Definition Name

Description

Function (macro)

assert

Adds diagnostics into programs.

To invalidate the diagnostics defined by <assert.h>, define macro name NDEBUG with a #define statement (#define NDEBUG) before including <assert.h>.

Note

If an #undef statement is used for macro name assert, the result of subsequent assert calls is not guaranteed.

 

assert

Adds diagnostics into programs.

[Format]

#include <assert.h>

void assert (long expression)

[Parameters]

expression Expression to be evaluated.

[Remarks]

When expression is true, the assert macro terminates processing without returning a value. If expression is false, it outputs diagnostic information to the standard error file in the form defined by the compiler, and then calls the abort function.

The diagnostic information includes the parameter's program text, source file name, and source line numbers.

Implementation define:
The following message is output when expression is false in assert (expression):
The message depends on the lang option setting at compilation.

(1) When -lang=c99 is not specified (C (C89), C++, or EC++ language):
ASSERTION FAILED:expressionFILE<file name>,
LINE<line number>

(2) When -lang=c99 is specified (C (C99) language):
ASSERTION FAILED:expressionFILE<file name>,
LINE<line number>FUNCNAME<function name>