assert.h 704 B

123456789101112131415161718192021222324
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Id$ */
  6. /* A S S E R T I O N M A C R O D E F I N I T I O N */
  7. /* This 'assert' definition can be used in a ,-expression. */
  8. #ifndef NDEBUG
  9. #if __STDC__
  10. int _BadAssertion(char *, int, char *);
  11. #define assert(exp) ((void)((exp) || _BadAssertion(__FILE__, __LINE__, #exp)))
  12. #else
  13. /* Note: this macro uses parameter substitution inside strings */
  14. #define assert(exp) ((exp) || _BadAssertion(__FILE__, __LINE__, "exp"))
  15. #endif
  16. #else
  17. #if __STDC__
  18. #define assert(exp) ((void)0)
  19. #else
  20. #define assert(exp) (0)
  21. #endif
  22. #endif /* NDEBUG */