# <assert.h>
<assert.h>
# ``
* * *
Include the standard header **``**
to define the macro
[`assert`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_assert.html#assert),
which is useful for diagnosing logic errors in
the program. You can eliminate the testing code produced by the macro
`assert` without removing the macro references from the program
by defining the macro
**`NDEBUG`**
in the program before you include
``. Each time the program includes this header,
it redetermines the definition of the macro `assert`.
#undef assert
#if defined NDEBUG
#define assert(test) (void)0
#else
#define assert(test)
#endifCopy to clipboard
## `assert`
#undef assert
#if defined NDEBUG
#define assert(test) (void)0
#else
#define assert(test)
#endifCopy to clipboard
If the *int* expression `test` equals zero,
the macro writes to
[`stderr`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stderr)
a diagnostic message that includes:
- the text of `test`
- the source filename (the predefined macro
[`__FILE__`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_preproc.html#__FILE__))
- the source line number (the predefined macro
[`__LINE__`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_preproc.html#__LINE__))
- the function name (the predefined object
[`__func__`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_preproc.html#__func__),
added with [C99](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_over.html#C99))
It then calls
[`abort`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdlib.html#abort).
You can write the macro `assert` in the program in any
[side-effects context](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_function.html#side-effects%20context).
* * *
See also the
**[Table of Contents](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_index.html#Table%20of%20Contents)** and the
**[Index](https://docs.qualcomm.com/doc/80-N3040-23/topic/_c_index.html)**.
*[Copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_crit_pjp.html) © 1992-2006by P.J. Plauger and Jim Brodie. All rights reserved.*
Last Published: Oct 06, 2026
[Previous Topic
Preprocessing](https://docs.qualcomm.com/bundle/publicresource/80-N3040-23/topics/c_preproc.md) Next Topic