fixed bug in prepareStackForAbsOpt (rtemgr.c).
[bugg-scheme-compiler.git] / src / c / assertions.h~
blobbbfa2d5d907494f88c70db23c70f465c96afbc68
1 /* assertions.h
2  * A custom assertion mechanism for C
3  * 
4  * Programmer: Mayer Goldberg, 1999
5  *
6  * Usage: To make use of the following custom assertion mechanism,
7  * include this file, and compile, when needed, with the -DDEBUG. Use
8  * ASSERT_DEBUG(expr) to assert a condition that must hold while
9  * debugging. Use ASSERT_ALWAYS(expr) to assert a condition that must
10  * hold always (also while not debugging).  
11  */
13 #ifndef __ASSERTIONS_H__
15 #define __ASSERTIONS_H__
17 #include <stdio.h>
18 #include <stdlib.h>
20 #ifdef DEBUG
22 #define ASSERT_DEBUG(e) \
23 do { \
24   if (! (e) ) { \
25     fprintf(stderr, \
26             "Failed assertion in file \"%s\", line %d:\n" \
27             "  ASSERT_DEBUG(%s);\n", \
28             __FILE__, __LINE__, #e); \
29     exit(-1); \
30   } \
31 } while (0)
33 #else
35 #define ASSERT_DEBUG(e) do {} while (0)
37 #endif
39 #define ASSERT_ALWAYS(e,msg) \
40 do { \
41   if (! (e) ) { \
42     fprintf(stderr, \
43             "Failed assertion in file \"%s\", line %d:\n" \
44             "  ASSERT_ALWAYS(%s);\n" \
45             "  %s", \
46             __FILE__, __LINE__, #e, msg); \
47     exit(-1); \
48   } \
49 } while (0)
51 #endif