home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / ansi / assert / assert.txh < prev    next >
Encoding:
Text File  |  1995-07-10  |  874 b   |  38 lines

  1. @node assert, misc
  2. @subheading Syntax
  3.  
  4. @example
  5. #define NDEBUG
  6. #include <assert.h>
  7.  
  8. assert(expression);
  9. assertval(expression);
  10. @end example
  11.  
  12. @subheading Description
  13.  
  14. These macros are used to assist in debugging.  The source code includes
  15. references to assert and assertval, passing them expressions that should
  16. be true (or non-zero).  When the expression equals zero, a diagnostic
  17. message is printed to stderr and the program aborts.
  18.  
  19. If you define the macro @code{NDEBUG} before including @file{assert.h},
  20. then the macros expand to nothing to reduce code size after debugging is
  21. done.
  22.  
  23. @subheading Return Value
  24.  
  25. @code{assert} returns one if it passes, else it aborts.
  26.  
  27. @code{assertval} returns the value of the expression if nonzero, else it
  28. aborts.
  29.  
  30. @subheading Example
  31.  
  32. @example
  33. int strdup(char *s)
  34. @{
  35.   assert(s != 0);
  36. @end example
  37.  
  38.