Variable length arg lists for macros
David A. Rabson
davidra at batcomputer.tn.cornell.edu
Fri Sep 2 09:48:41 AEST 1988
(Summary: people complain about lack of variable-length arg lists for
macros. Standards people try to cover themselves. Other people point
out that (( ... )) often works almost as well as variable-length arg list.)
There is another way to fake out at least some preprocessors. I find the
following useful in header files. The header file is included in several
code files only one of which defines GLOBALS.
#undef INIT
#undef COMMA
#define COMMA ,
#ifdef GLOBALS
#define INIT(x) =x
#else
#define INIT(x) /*nop*/
#endif
extern int x[2] INIT({1 COMMA 2});
Since the (( )) and COMMA kludges cover all the cases where I might have
wanted variable-length argument lists in cpp macros, I have to agree
that the extension would be unnecessary
David Rabson
Laboratory of Atomic and Solid State Physics
More information about the Comp.std.c
mailing list