C - Diagnostics

From EdWiki

Revision as of 09:30, 23 June 2015 by Jshankar (Talk | contribs) (1 revision imported: EdWiki -- Emsys pages from Shukra)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


The assert macro is used to add diagnostics to programs.

void assert( int expression )

If expression is zero when assert(expression) is executed, the assert macro will print a message on stderr, such as

Assertion failed: expression, file filename, line nnnn.

It then calls abort to terminate execution. The source filename and line number come from the preprocessor macros __FILE__ and __LINE__.

If NDEBUG is defined at the time is included, the assert macro is ignored.