2 * A custom assertion mechanism for C
4 * Programmer: Mayer Goldberg, 1999
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).
13 #ifndef __ASSERTIONS_H__
15 #define __ASSERTIONS_H__
22 #define ASSERT_DEBUG(e) \
26 "Failed assertion in file \"%s\", line %d:\n" \
27 " ASSERT_DEBUG(%s);\n", \
28 __FILE__, __LINE__, #e); \
35 #define ASSERT_DEBUG(e) do {} while (0)
39 #define ASSERT_ALWAYS(e,msg) \
43 "Failed assertion in file \"%s\", line %d:\n" \
44 " ASSERT_ALWAYS(%s);\n" \
46 __FILE__, __LINE__, #e, msg); \