Article View: comp.std.c
Article #5307Re: Variable length arg lists for macros
From: David A. Rabson
Date: Thu, 01 Sep 1988 23:48
Date: Thu, 01 Sep 1988 23:48
27 lines
1396 bytes
1396 bytes
(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
Technical Details
Message-ID:
<6191@batcomputer.tn.cornell.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!batcomputer!davidraReferences:
<438@ucsvc.unimelb.edu.au> <1036@cbnews.ATT.COM> <429@thirdi.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!batcomputer!davidra From: davidra@batcomputer.tn.cornell.edu (David A. Rabson) Newsgroups: comp.std.c,comp.lang.c Subject: Re: Variable length arg lists for macros Message-ID: <6191@batcomputer.tn.cornell.edu> Date: 1 Sep 88 23:48:41 GMT References: <438@ucsvc.unimelb.edu.au> <1036@cbnews.ATT.COM> <429@thirdi.UUCP> Reply-To: davidra@tcgould.tn.cornell.edu (David A. Rabson) Organization: Cornell Theory Center, Cornell University, Ithaca NY Lines: 27