Path: 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 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.