(when programming:) A statement of a condition which is guaranteed to be true at that point of the program during its execution. It can't happen that an assertion fails. Since often it does, assertions can be invaluable debugging aids. They also have high value as documentation.
In C, assertions are introduced using "
assert() is a macro defined in the standard header file assert.h. If the macro
#defined, it does nothing. Otherwise, it compiles to code which tests that COND is true, and
abort()s (printing some indication of the assertion and the point of failure) if COND is false.
Recall that an assertion "cannot" fail! Thus, both versions (without and with
NDEBUG) must be exactly the same. However, when compiling a version for debugging, the version which gives an indication of failure is invaluable.