From 3e64df195685dc6fc42475908a5b33b59543bb57 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Wed, 29 Jul 2009 07:54:33 +0000 Subject: [PATCH] Add CHECK(p), like ASSERT(p) but works even when !defined(DEBUG) For inexpensive assertions --- includes/Rts.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/includes/Rts.h b/includes/Rts.h index b5737d4..690c170 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 */ /* -- 1.7.10.4