util: better fix for unused variable warnings with asserts
authorKeith Whitwell <keithw@vmware.com>
Mon, 28 Dec 2009 11:05:06 +0000 (11:05 +0000)
committerKeith Whitwell <keithw@vmware.com>
Mon, 28 Dec 2009 11:06:11 +0000 (11:06 +0000)
Modify the non-debug (ie disabled) version of assert to expose the
value in the expression to the compiler (avoiding the unused variable
messages) while still expanding to a noop.

src/gallium/auxiliary/util/u_debug.h

index abd834c..facc30a 100644 (file)
@@ -188,7 +188,7 @@ void _debug_assert_fail(const char *expr,
 #ifdef DEBUG
 #define debug_assert(expr) ((expr) ? (void)0 : _debug_assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
 #else
-#define debug_assert(expr) ((void)0)
+#define debug_assert(expr) do { } while (0 && (expr))
 #endif