assert()

insert diagnostics into programs 

Function


SYNOPSIS

#include <assert.h>

void assert(int expression);


DESCRIPTION

The assert() macro inserts diagnostics into programs. When it is executed, if expression is false (that is, compares equal to 0), the assert() macro writes information about the particular call that failed on the standard error file in an implementation-defined format. The written information includes the text of the parameter, the name of the source file, and the source line number. (The latter are, respectively, the values of the preprocessing macros __FILE__ and __LINE__.) Then, the assert() macro calls the abort() function.

Forcing a definition of the name NDEBUG, either from the compiler command line or with the preprocessor control statement #define NDEBUG prior to including <assert.h>, stops assertions from being compiled into the program.


PARAMETERS

expression 

Is an integer expression expected to be true at this point in the program. expression may not contain any string literals.


RETURN VALUES

None.


CONFORMANCE

ANSI/ISO 9899-1990.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

Windows-subsystem applications (that is, pure GUI) do not have their stdio streams attached to a text-mode console by default. You need to either explicitly attach a console (see /dev/console), or us an alternate mechanism to display assertion failures.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
cc

Functions:
abort()


PTC MKS Toolkit 10.4 Documentation Build 39.