Stops execution if a test fails.
#include <assert.h> void assert(int expression);
expression
The result of a boolean expression.
If expression is false the assert() macro outputs a diagnostic message and calls abort().
To disable assert() macros, place a #define NDEBUG (no debugging) directive before the #include <assert.h> directive.
Because calls to assert() may be disabled, make sure that your program does not depend on the effects of computing the value of expression.
This facility may have limited capability on configurations of the EWL that run on platforms that do not have console input/output or a file system.
/* Make sure that assert() is enabled. */ #undef NDEBUG #include <assert.h> #include <stdio.h> int main(void) { int x = 100, y = 5; printf("assert test.\n"); /* This assert will output a message and abort the program */ assert(x > 1000); printf("This will not execute if NDEBUG is undefined\n"); return 0; }