Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- libc - <b>assert</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
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);


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson