From: Philippe Proulx Date: Tue, 5 Jun 2018 21:50:45 +0000 (-0400) Subject: BT_ASSERT_PRE(): when disabled, use the expression anyway X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=ebbc3f14febbf0152c4d98dac9abecc898dfae08;p=deliverable%2Fbabeltrace.git BT_ASSERT_PRE(): when disabled, use the expression anyway Apply to the BT_ASSERT_PRE() macro (and its derivatives) the same trick used for BT_ASSERT() to use the condition without evaluating it when the macro is disabled. This avoids unused variable compiler warnings in a production build. Signed-off-by: Philippe Proulx --- diff --git a/include/babeltrace/assert-pre-internal.h b/include/babeltrace/assert-pre-internal.h index 583647364..74a8b9e22 100644 --- a/include/babeltrace/assert-pre-internal.h +++ b/include/babeltrace/assert-pre-internal.h @@ -98,7 +98,7 @@ */ # define BT_ASSERT_PRE_MSG BT_LIB_LOGF #else -# define BT_ASSERT_PRE(_cond, _fmt, ...) +# define BT_ASSERT_PRE(_cond, _fmt, ...) ((void) sizeof((void) (_cond), 0)) # define BT_ASSERT_PRE_FUNC BT_UNUSED # define BT_ASSERT_PRE_MSG(_fmt, ...) #endif /* BT_DEV_MODE */