www.delorie.com/djgpp/doc/libc/libc_48.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]



#define NDEBUG
#include <assert.h>



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

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

Return Value

assert returns 1 if its argument is non-zero, else it aborts.

assertval returns the value of its expression argument, if non-zero, else it aborts.


ANSI/ISO C C89; C99 (see note 1)
POSIX 1003.2-1992; 1003.1-2001 (see note 2)


  1. assert is ANSI, assertval is not.
  2. assert is Posix, assertval is not.


/* Like `strdup', but doesn't crash if the argument is NULL.  */
char * safe_strdup(const char *s)
  assert(s != 0);
  return strdup(s);

  webmaster     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004