assert.h 615 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * assert.h - diagnostics
  3. *
  4. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  5. * See the copyright notice in the ACK home directory, in the file "Copyright".
  6. */
  7. /* $Id$ */
  8. #ifndef _ASSERT_H
  9. #define _ASSERT_H
  10. extern void __bad_assertion(const char *_mess);
  11. #undef assert
  12. #define __str(x) # x
  13. #define __xstr(x) __str(x)
  14. #if defined(NDEBUG)
  15. #define assert(ignore) ((void)0)
  16. #else
  17. #define assert(expr) ((expr)? (void)0 : \
  18. __bad_assertion("Assertion \"" #expr \
  19. "\" failed, file " __xstr(__FILE__) \
  20. ", line " __xstr(__LINE__) "\n"))
  21. #endif /* NDEBUG */
  22. #endif