assert.h is a header file in the standard library of the C programming language that defines the C preprocessor macro assert(). The macro implements an assertion, which can be used to verify assumptions made by the program.

The assert() macro inserts diagnostics into programs. When executed, if the expression is false (that is, compares equal to 0), assert() writes information about the call that failed on stderr and then calls abort(). The information it writes to stderr includes:

  • the text of expression that evaluated to 0
  • the source filename (the predefined macro __FILE__)
  • the source line number (the predefined macro __LINE__)

Programmers 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 including . If NDEBUG is defined as a macro name before the inclusion of this header, the assert() macro is defined simply as:

#define assert(ignore)((void) 0)

and therefore has no effect on the program.

The assert() macro is implemented as a macro, not as a function. If the macro definition is suppressed in order to access an actual function, the behaviour is undefined.

Search another word or see asserton Dictionary | Thesaurus |Spanish
Copyright © 2015, LLC. All rights reserved.
  • Please Login or Sign Up to use the Recent Searches feature