This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEBUGGING: Macros with variable parameter list?

Hi,

has the C compiler/preprocessor the ability to translate "variadic macros" - Macros with a variable parameter list like in the Ansi C99 standard? If not, how can one implement a debug printf (variable parameter count) that is completely removed in the production code is?

Description of GNU C:
"A macro can be declared to accept a variable number of arguments much as a function can... Here is an example:

#define eprintf(...) fprintf (stderr, __VA_ARGS__)

This kind of macro is called variadic. When the macro is invoked, all the tokens in its argument list after the last named argument ... of tokens replaces the identifier __VA_ARGS__ in the macro body wherever it appears:

eprintf ("%s:%d: ", input_file, lineno)
==> fprintf (stderr, "%s:%d: ", input_file, lineno)"

0