Make debug_assert noop on NDEBUG
Reviewers: mferencevic Reviewed By: mferencevic Subscribers: mferencevic, pullbot Differential Revision: https://phabricator.memgraph.io/D634
This commit is contained in:
parent
cc8e9f2996
commit
599e5651af
@ -164,14 +164,6 @@ endif()
|
||||
|
||||
# custom assert control parameters
|
||||
|
||||
# Debug assert, if value is OFF debug asserts will be inactive.
|
||||
# Default value is ON.
|
||||
option(DEBUG_ASSERT "Enable debug assertions" ON)
|
||||
message(STATUS "DEBUG_ASSERT: ${DEBUG_ASSERT}")
|
||||
if(DEBUG_ASSERT)
|
||||
add_definitions(-DDEBUG_ASSERT_ON)
|
||||
endif()
|
||||
|
||||
# by default on custom assert only the message, filename and line number will be
|
||||
# printed on stderr, if STACKTRACE_ASSERT is ON the whole stacktrace is going to
|
||||
# be printed on stderr
|
||||
|
@ -73,8 +73,8 @@
|
||||
* @def debug_assert(condition, message)
|
||||
* Check that the condition is satisfied, otherwise abort the program.
|
||||
*
|
||||
* This is like @c permanent_assert, but the @c DEBUG_ASSERT_ON define controls
|
||||
* whether this assertion is active. Without the define, @c debug_assert will do
|
||||
* This is like @c permanent_assert, but the @c NDEBUG define controls
|
||||
* whether this assertion is active. With this define, @c debug_assert will do
|
||||
* nothing. Therefore, this is more like the standard C @c assert facility and
|
||||
* it should be used as such. For example, validating pre and post conditions of
|
||||
* a function.
|
||||
@ -88,8 +88,8 @@
|
||||
* @def debug_fail(message)
|
||||
* Abort the program with given message.
|
||||
*
|
||||
* This is like @c permanent_fail, but the @c DEBUG_ASSERT_ON define controls
|
||||
* whether this assertion is active. Without the define, @c debug_fail will do
|
||||
* This is like @c permanent_fail, but the @c NDEBUG define controls
|
||||
* whether this assertion is active. With this define, @c debug_fail will do
|
||||
* nothing. This should be used like @c debug_assert, but when the condition
|
||||
* cannot be a simple expression.
|
||||
*
|
||||
@ -98,7 +98,7 @@
|
||||
* @sa permanent_fail
|
||||
*/
|
||||
|
||||
#ifdef DEBUG_ASSERT_ON
|
||||
#ifndef NDEBUG
|
||||
#define debug_assert(condition, message) permanent_assert(condition, message)
|
||||
#define debug_fail(message) permanent_fail(message)
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user