assert


Adds diagnostic features to the program.

[Classification]

Standard library

[Syntax]

#include <asssert.h>

assert(int expression);

[Description]

If expression is true, ends processing without returning a value. If expression is false, it outputs diagnostic information to the standard error file in the format defined by the compiler, and then calls the abort functionNote.

The diagnostic information includes the program text of the parameters, the name of the source file, and the line number of the source.

 

If you wish to disable the assert macro, include a #define NDEBUG statement before assert.h is loaded.

Note

If you use the assert macro, you must create an abort function in accordance with the user system.

[Example]

#include    <assert.h>
int func(void);
int main() {
    int ret;
    ret = func();
    assert(ret == 0);       <- abort() is called if ret is not 0
    return 0;
}