Now that all the C pre-processors in use support variadic macros, make
DEBUG_ONLY work with toplevel commas (i.e. commas which are outside of
any parentheses pair). This is useful in at least 2 ways:
In C code, to easily pass debug arguments to functions in debug builds
without any overhead in non-debug builds.
void
foo(DEBUG_ONLY(int debugArg,) // IN
int nonDebugArg) // IN
{
ASSERT(DebugFunc(debugArg));
NonDebugFunc(nonDebugArg);
}
foo(DEBUG_ONLY(debugArg,) nonDebugArg);
In asm code.
DEBUG_ONLY(mov x0, #0)
#undef DEBUG_ONLY
#ifdef VMX86_DEBUG
#define vmx86_debug 1
-#define DEBUG_ONLY(x) x
+#define DEBUG_ONLY(...) __VA_ARGS__
#else
#define vmx86_debug 0
-#define DEBUG_ONLY(x)
+#define DEBUG_ONLY(...)
#endif
#ifdef VMX86_STATS