diff options
author | Simon Marlow <marlowsd@gmail.com> | 2009-07-29 07:54:33 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2009-07-29 07:54:33 +0000 |
commit | 3e64df195685dc6fc42475908a5b33b59543bb57 (patch) | |
tree | 703f0bf10699551b98e6f4c6ea11fd6a9b5540c8 /includes | |
parent | 1b6914d8a2ad53353651acf62a21a305e9b83876 (diff) | |
download | haskell-3e64df195685dc6fc42475908a5b33b59543bb57.tar.gz |
Add CHECK(p), like ASSERT(p) but works even when !defined(DEBUG)
For inexpensive assertions
Diffstat (limited to 'includes')
-rw-r--r-- | includes/Rts.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/includes/Rts.h b/includes/Rts.h index b5737d4d0e..690c170fa1 100644 --- a/includes/Rts.h +++ b/includes/Rts.h @@ -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 */ /* |