Variadic macro in the C preprocessor

[2][3] The declaration syntax is similar to that of variadic functions: a sequence of three full stops "..." is used to indicate that one or more arguments must be passed.

[12] If a printf-like function dbgprintf() were desired, which would take the file and line number from which it was called as arguments, the following solution applies.

Due to limitations of the variadic macro support in C++11 the following straightforward solution can fail and should thus be avoided:The reason is that gets expanded to circumvent the abovementioned incompatibilities.

There is a portability issue with generating a trailing comma with empty args for variadic macros in C99.

[3] Before the existence of variable-arguments in C99, it was quite common to use doubly nested parentheses to exploit the variable number of arguments that could be supplied to the printf() function: dbgprintf() could then be called as: which expands to: