assert.h 865 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. /* At some points in the program, it must be sure that some condition
  8. holds true, due to further, successful, processing. As long as
  9. there is no reasonable method to prove that a program is 100%
  10. correct, these assertions are needed in some places.
  11. */
  12. #include "debug.h" /* UF */
  13. #ifdef DEBUG
  14. /* Note: this macro uses parameter substitution inside strings */
  15. #define ASSERT(exp) (exp || crash("in %s, %u: assertion %s failed", \
  16. __FILE__, __LINE__, "exp"))
  17. #define NOTREACHED() crash("in %s, %u: unreachable statement reached", \
  18. __FILE__, __LINE__)
  19. #else
  20. #define ASSERT(exp)
  21. #define NOTREACHED()
  22. #endif /* DEBUG */