🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5329

Faking out CPP (was: Variable length arg lists for macros)

#5329
From: Chris Quenelle
Date: Wed, 07 Sep 1988 17:00
38 lines
1502 bytes
One common thread to this discussion is "ways to 'define out'
a function call with a variable number of parameters".

for instance, you have :

	DEBUG_fprintf(stderr,"error number %d\n", errnumber);

and you would like a define that "disables" it, by making compile
to nothing when a certain define is set.

I have tried 

#define DEBUG_fprintf	1 ? 0 :

and it is guaranteed not to _call_ DEBUG_fprintf, but it MAY generate
code for it.  Actually any decent compiler should throw it away entirely.

The effect is as if you had done something like this:

	statement;
	5;
	other-statement;

	or

	statement;
	1 ? 5 : 7;
	other-statement;

both perfectly legal C.

"works for me."

--chris
-----------------------------|@---@    -=----|---------------------------------
|Chris Quenelle (The Lab Rat)|\. ./ + --==---|   on hold                      |
|ucbvax!voder!polyslo!cquenel| \ /   ---===--|                                |
-----------------------------|==o== ----====-|---------------------------------
Technical Details
Message-ID: <38546@pyramid.pyramid.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!mailrus!ames!pasteur!ucbvax!hplabs!pyramid!cquenel

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!mailrus!ames!pasteur!ucbvax!hplabs!pyramid!cquenel
From: cquenel@pyrglass (Chris Quenelle)
Newsgroups: comp.std.c,comp.lang.c
Subject: Faking out CPP (was: Variable length arg lists for macros)
Message-ID: <38546@pyramid.pyramid.com>
Date: 7 Sep 88 17:00:04 GMT
Sender: daemon@pyramid.pyramid.com
Reply-To: cquenel@pyrglass.UUCP (Chris Quenelle)
Organization: Pyramid Technology Corp., Mountain View, CA
Lines: 38