C Programming/assert.h/assert
Appearance
(Redirected from C Programming/C Reference/assert.h/assert)
Definition
[edit | edit source]void assert(expression);
Return value
[edit | edit source]The assert
macro returns a void
, i.e. no value.
Notes
[edit | edit source]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
.