Commit 3e64df19 authored by Simon Marlow's avatar Simon Marlow

Add CHECK(p), like ASSERT(p) but works even when !defined(DEBUG)

For inexpensive assertions
parent 1b6914d8
......@@ -70,19 +70,23 @@ extern "C" {
/* -----------------------------------------------------------------------------
Assertions and Debuggery
-------------------------------------------------------------------------- */
#ifndef DEBUG
#define ASSERT(predicate) /* nothing */
#else
CHECK(p) evaluates p and terminates with an error if p is false
ASSERT(p) like CHECK(p) if DEBUG is on, otherwise a no-op
-------------------------------------------------------------------------- */
extern void _assertFail (const char *, unsigned int);
#define ASSERT(predicate) \
#define CHECK(predicate) \
if (predicate) \
/*null*/; \
else \
_assertFail(__FILE__, __LINE__)
#ifndef DEBUG
#define ASSERT(predicate) /* nothing */
#else
#define ASSERT(predicate) CHECK(predicate)
#endif /* DEBUG */
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment