🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5320

Re: Variable length arg lists for macros

#5320
From: Glenn Fowler[eww]
Date: Thu, 01 Sep 1988 16:13
28 lines
1541 bytes
In article <438@ucsvc.unimelb.edu.au>, u5565522@ucsvc.unimelb.edu.au (David Clunie) writes:
> ... 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
> ... Probably a bit late for the ANSI standard ...

too late, but here is the description of macro `...' args for
a local preprocessor extension:

	If the last formal argument is followed by the `...'
	token then it is replaced by the expanded value
	of all remaining actual arguments and intervening `,'
	tokens from the macro call.  If there is only one formal
	argument then the macro may be called with no actual
	arguments, otherwise there must be at least one actual
	argument for the last formal argument.

this would change the tracef() macro definition to

	#define tracef(s,...)	printf(s)

the `,' before the `...' is optional to satisfy all tastes
-- 
    Glenn Fowler                    AT&T Bell Laboratories, Murray Hill
    {ihnp4,allegra}!ulysses!gsf                          (201)-582-2195
Technical Details
Message-ID: <10568@ulysses.homer.nj.att.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!seismo!sundc!pitstop!sun!amdcad!ames!pasteur!ucbvax!ulysses!gsf
References: <438@ucsvc.unimelb.edu.au>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!seismo!sundc!pitstop!sun!amdcad!ames!pasteur!ucbvax!ulysses!gsf
From: gsf@ulysses.homer.nj.att.com (Glenn Fowler[eww])
Newsgroups: comp.std.c
Subject: Re: Variable length arg lists for macros
Summary: macro ... description
Message-ID: <10568@ulysses.homer.nj.att.com>
Date: 1 Sep 88 16:13:35 GMT
References: <438@ucsvc.unimelb.edu.au>
Organization: AT&T Bell Laboratories, Murray Hill
Lines: 28