> Is there any way to support variadic macros in Visual Studio like gcc
> supports? If not, how do people write stuff like custom
> asserts that take variable parameters?
If the variable parameters are ultimately destined to go into a printf-like
function (which I guess is the common case), we do the following:
PRINT(dbg_category)("%d %d", something, something)
dbg_category is on object of a class use to categorize debug printout
messages, e.g. to filter them, to disable them selectively etc.
This expands to something like that:
dbgCategory.Enabled() ? 0 : GlobalSetFileLine(__FILE__, __LINE__) ? 0 : dbgCategory.Print
Where the Print method of the debug categories is variadic and transfers its va_arg to
a real sprintf.
|