This documentation is copyright © 1998-2001 Sandro Sigala <sandro@sigala.it>.
All rights reserved.
Released under the GNU General Public License.
NDEBUG
Prototype
#define NDEBUG
#include <assert.h>
Description
The NDEBUG
macro is the sole symbol
that is not defined by the standard C library, but may be defined
by the user before including the <assert.h>
header.
This is useful after the editing-debug phase of the software development,
when the user have assured that the various assert
checks are never
false.
When the NDEBUG
macro is defined before the inclusion
of the <assert.h>
header, the assert
macro
is defined to a null value like this:
#define assert(e) ((void)0)
All the debugging assert
checks are then avoided.
Example
#define NDEBUG /* Debug phase finished. */
#include <assert.h>
#include <stdlib.h>
#include <string.h>
/* See assert() for the definition. */
extern void *xmalloc(size_t size);
/*
* Return a duplicate of the argument string, allocating
* dynamically a memory area.
*/
char *xstrdup(const char *s)
{
char *ns;
assert(s != NULL); /* Catch invalid arguments. */
ns = (char *)xmalloc(strlen(s) + 1);
assert(ns != NULL); /* Catch unexpected behaviors. */
strcpy(ns, s);
return ns;
}
References
ISO C 9899:1990 7.2, ISO C 9899:1999 7.2