home *** CD-ROM | disk | FTP | other *** search
/ ANews 3 / AnewsCD3.iso / DP / Programmation / GCC / gcc_include / assert.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-15  |  990 b   |  47 lines

  1. /* Assert macro for GNU CC                                                            */
  2. /* Allow this file to be included multiple times with different settings of NDEBUG.    */
  3.  
  4. #undef    assert
  5. #undef    __assert
  6.  
  7. #ifndef    DEBUG
  8. #define assert(ignore)  ((void)0)
  9. #else
  10.  
  11. #ifdef    __cplusplus
  12. extern "C" {
  13. #endif
  14.  
  15. extern void    __eprintf();
  16. extern void    abort(void);
  17.  
  18. #ifdef    __cplusplus
  19. }
  20. #endif
  21.  
  22.  
  23. #ifdef __STDC__
  24.  
  25. #define assert(expression)    \
  26.   ((expression) ? 0 : (__assert (#expression, __FILE__, __LINE__), 0))
  27.  
  28. #define __assert(expression, file, line)                        \
  29.   (__eprintf ("Failed assertion `%s' at line %d of `%s'.\n",    \
  30.           expression, line, file),                                \
  31.    abort ())
  32.  
  33. #else /* no __STDC__; i.e. -traditional.  */
  34.  
  35. #define assert(expression)    \
  36.   ((expression) ? 0 : __assert (expression, __FILE__, __LINE__))
  37.  
  38. #define __assert(expression, file, lineno)                        \
  39.   (__eprintf ("Failed assertion `%s' at line %d of `%s'.\n",    \
  40.           "expression", lineno, file),                            \
  41.    abort ())
  42.  
  43. #endif /* no __STDC__; i.e. -traditional.  */
  44.  
  45. #endif
  46.  
  47.