< C Programming < assert.h
assert
Prototype
void assert(expression);
Return value
The assert
macro returns a void
, i.e. no value.
Notes
The behaviour of the assert
macro depends on the value of the NDEBUG
macro. See assert.h for more details.
If NDEBUG
is defined then the macro assert
, regardless of argument, is defined as
#define assert(expression) ((void) 0)
If NDEBUG
is not defined the assert
macro acts as a diagnostic test. If the expression
argument of the macro is false (see C Programming/Control), then the macro expands to a statement which writes the text of the argument, the present file name, line number and function name to the standard error stream. Finally the assert
macro calls the abort()
function.
Each time the assert.h
header is included the assert
macro is redefined depending on the value of NDEBUG
.
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.