home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntinc25.zoo / assert.h < prev    next >
C/C++ Source or Header  |  1992-09-17  |  1KB  |  70 lines

  1. /*
  2.  * assert.h
  3.  *    sec 4.2 ansi draft
  4.  */
  5.  
  6. /* Allow this file to be included multiple times
  7.    with different settings of NDEBUG.  */
  8. #undef assert
  9. #undef assertval
  10.  
  11. #ifndef _COMPILER_H
  12. #include <compiler.h>
  13. #endif
  14.  
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18.  
  19.  
  20. __EXTERN void __eprintf __PROTO((const char *expression, const long line,
  21.                  const char *filename));
  22. __EXTERN __EXITING abort __PROTO((void));
  23.  
  24. #ifdef __cplusplus
  25. }
  26. #endif
  27.  
  28.  
  29. #ifdef NDEBUG
  30. #define    assert(cond)
  31. #define assertval(cond)
  32. #else
  33.  
  34. #if __STDC__
  35. #define assert(cond) \
  36. if(!(cond)) \
  37.     { __eprintf(#cond,(long)(__LINE__), __FILE__); abort(); }
  38.  
  39. #define assertval(cond) \
  40. ((cond) ? 1 : \
  41.     ( __eprintf(#cond,(long)(__LINE__), __FILE__), abort(), 0 ))
  42. #else
  43.  
  44.  
  45. #ifndef __SOZOBON__
  46. /* There's a bug in Sozobon 2.0 whereby __LINE__ & __FILE__ are defined but
  47.  * testing #ifndef __?I?E__ comes out as if they aren't. */
  48.  
  49. #ifndef __LINE__
  50. #define __LINE__ 0
  51. #endif
  52. #ifndef __FILE__
  53. #define __FILE__ "unknown"
  54. #endif
  55.  
  56. #endif /* __SOZOBON__ */
  57.  
  58. #define assert(cond) \
  59. if(!(cond)) \
  60.     { __eprintf("cond", (long)(__LINE__), __FILE__); abort(); }
  61.  
  62. #define assertval(cond) \
  63. ((cond) ? 1:  \
  64.     ( __eprintf("cond", (long)(__LINE__), __FILE__), abort(), 0))
  65.  
  66. #endif /* __STDC__ */
  67.  
  68.  
  69. #endif /* NDEBUG */
  70.