Variable length arg lists for macros
David Clunie
u5565522 at ucsvc.unimelb.edu.au
Wed Aug 31 22:41:09 AEST 1988
How do people feel about the idea of preprocessor macros with variable
length argument lists ?
The concept has already been enshrined for true functions, allowing
protoypes for things like the printf() family of functions, and a set of
portable functions and macros to access the list of arguments.
However this can not be done with macro calls. Wouldn't it be nice to be
able to do something like ...
#ifdef TRACE
#define tracef(s,...) printf(s,...)
#else
#define tracef(s,...) /* nothing */
#endif
At present, this CANNOT BE DONE, without nesting parentheses (clumsy) or
using a call to an empty function (inefficient, unless you have inline
integration in an optimizing compiler).
Just a thought. Probably a bit late for the ANSI standard. I am certainly
going to put it in my compiler though !!!
Regards ... David Clunie
More information about the Comp.std.c
mailing list