BT_ASSERT_PRE(): when disabled, use the expression anyway
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 5 Jun 2018 21:50:45 +0000 (17:50 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 04:05:45 +0000 (00:05 -0400)
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 <eeppeliteloop@gmail.com>
include/babeltrace/assert-pre-internal.h

index 58364736441b7508cec33d5b1452225fcc2e5f87..74a8b9e2254b6d84d82a679bc8bf6adc9472b39a 100644 (file)
@@ -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 */
This page took 0.024908 seconds and 4 git commands to generate.