www.delorie.com/djgpp/doc/libc-2.01/libc_43.html   search  
Go to the first, previous, next, last section, table of contents.


assert

Syntax

#define NDEBUG
#include <assert.h>

assert(expression);
assertval(expression);

Description

These macros are used to assist in debugging. The source code includes references to assert and assertval, passing them expressions that should be true (or non-zero). When the expression equals zero, a diagnostic message is printed to stderr and the program aborts.

If you define the macro NDEBUG before including `assert.h', then the macros expand to nothing to reduce code size after debugging is done.

Return Value

assert returns one if it passes, else it aborts.

assertval returns the value of the expression if nonzero, else it aborts.

Example

int strdup(char *s)
{
  assert(s != 0);


Go to the first, previous, next, last section, table of contents.

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 1997   by DJ Delorie     Updated Apr 1997  

Please take a moment to fill out this visitor survey
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)