🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5316

Variable length arg lists for macros

#5316
From: David Clunie
Date: Wed, 31 Aug 1988 12:41
30 lines
1276 bytes
How do people feel about the idea of preprocessor macros with variable
length argument lists ?

The concept has already been enshrined for true functions, allowing
protoypes for things like the printf() family of functions, and a set of
portable functions and macros to access the list of arguments.

However this can not be done with macro calls. 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


At present, this CANNOT BE DONE, without nesting parentheses (clumsy) or
using a call to an empty function (inefficient, unless you have inline
integration in an optimizing compiler).

Just a thought. Probably a bit late for the ANSI standard. I am certainly
going to put it in my compiler though !!!

	Regards ... David Clunie
Technical Details
Message-ID: <438@ucsvc.unimelb.edu.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!amdcad!sun!pitstop!sundc!seismo!uunet!munnari!murdu!ucsvc!u5565522

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!ames!amdcad!sun!pitstop!sundc!seismo!uunet!munnari!murdu!ucsvc!u5565522
From: u5565522@ucsvc.unimelb.edu.au (David Clunie)
Newsgroups: comp.std.c
Subject: Variable length arg lists for macros
Message-ID: <438@ucsvc.unimelb.edu.au>
Date: 31 Aug 88 12:41:09 GMT
Organization: The University of Melbourne
Lines: 30