delorie.com/djgpp/doc/libc/libc_48.html | search |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#define NDEBUG #include <assert.h> assert(expression); assertval(expression); |
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.
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) |
Notes:
assert
is ANSI, assertval
is not.
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 | Updated Apr 2004 |