Article View: comp.std.c
Article #5910Re: Variable arguments in macros
From: Doug Gwyn
Date: Tue, 18 Apr 1989 13:41
Date: Tue, 18 Apr 1989 13:41
17 lines
1052 bytes
1052 bytes
In article <89Apr17.163342edt.11027@ephemeral.ai.toronto.edu> bradb@ai.toronto.edu (Brad Brown) writes:
>I've been trying to find a way to have macros with variable numbers of
>arguments in ANSI C, and I don't think it can be done.
Not as such.
There is a trick that is sometimes convenient (but not in this
particular case):
#define FOO(x) bar x
FOO((a,b,c)) /* expands to: bar (a,b,c) */
>What I'd like to do is have a header file with a macro similar to
> #define trace(s) { fprintf( stderr, s ); }
What I do for this is to define a variable-argument function that
invokes vfprintf() to do the printing.
Technical Details
Message-ID:
<10068@smoke.BRL.MIL>Path:
arc1-ca.pugleaf.net!utzoo!dptcdc!jarvis.csri.toronto.edu!mailrus!ncar!ames!haven!adm!smoke!gwynReferences:
<89Apr17.163342edt.11027@ephemeral.ai.toronto.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!dptcdc!jarvis.csri.toronto.edu!mailrus!ncar!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: Variable arguments in macros Message-ID: <10068@smoke.BRL.MIL> Date: 18 Apr 89 13:41:46 GMT References: <89Apr17.163342edt.11027@ephemeral.ai.toronto.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 17