From 670fa88a98c7e12c4e2e948d92476918d3048f7e Mon Sep 17 00:00:00 2001 From: David Steele Date: Thu, 18 Apr 2019 13:21:24 -0400 Subject: [PATCH] Add CHECK() macro for production assertions. CHECK() works just like ASSERT() but is kept in production builds. --- doc/xml/release.xml | 4 ++++ src/common/assert.h | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index e7ce6a962..614e85e50 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -29,6 +29,10 @@

Move lockRelease() to the end of exitSafe().

+ +

Add CHECK() macro for production assertions.

+
+

Automatically generate constants for command and option names.

diff --git a/src/common/assert.h b/src/common/assert.h index 00c25dd22..e1fa6d0d5 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -21,5 +21,15 @@ Asserts are used in test code to ensure that certain conditions are true. They #define ASSERT(condition) #endif +/*********************************************************************************************************************************** +Checks are used in production builds to test very important conditions. Be sure to limit use to the most critical cases. +***********************************************************************************************************************************/ +#define CHECK(condition) \ + do \ + { \ + if (!(condition)) \ + THROW_FMT(AssertError, "check '%s' failed", #condition); \ + } \ + while (0) #endif