1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-17 01:12:23 +02:00

Add ASSERT() that is preserved in production builds.

This commit is contained in:
David Steele
2018-03-30 19:10:34 -04:00
parent a8721ffe11
commit 635caff573
5 changed files with 31 additions and 7 deletions

View File

@ -15,15 +15,21 @@ NDEBUG indicates to C library routines that debugging is off -- set a more reada
/***********************************************************************************************************************************
Assert Macros
Used for assertions that should only be run when debugging. Ideal for conditions that are not likely to happen in production but
could occur during development.
***********************************************************************************************************************************/
// For very important asserts that are shipped with the production code.
#define ASSERT(condition) \
{ \
if (!(condition)) \
THROW(AssertError, "assertion '%s' failed", #condition); \
}
// Used for assertions that should only be run when debugging. Ideal for conditions that are not likely to happen in production but
// could occur during development.
#ifdef DEBUG
#define ASSERT_DEBUG(condition) \
{ \
if (!(condition)) \
THROW(AssertError, "assertion '%s' failed", #condition); \
THROW(AssertError, "debug assertion '%s' failed", #condition); \
}
#else
#define ASSERT_DEBUG(condition)