🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9555

Re: Disappearing function call

#9555
From: mcg
Date: Sun, 12 Oct 1986 22:22
29 lines
1430 bytes
You guys are all thinking too hard.  Even the venerable Chris Torek has
proposed a solution more complex than needed.  On any compiler likely to
be used for production code, the optimizer will generate no code
whatsoever for the following fragment:

	#define DEBUG	0	/* set to 1 to turn debugging on */

	...

	if (DEBUG) debug(...);

Similarly, in the case of '#define DEBUG 1', the unneccesary test will
be elided.
 
In the idiom of the original posting, the example is:

	#define	debug	if(DEBUG) debug

	debug(x,y,z);

Though care must be taken in using this form in un-braced if statements
that have else clauses.

The preprocessor solutions have the intoxicating air of complexity about
them, but, in my experience, this solution proves easiest and most
effective.  Why look for trouble?  Trouble will find you.

S. McGeady
Technical Details
Message-ID: <162@omepd>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!rutgers!husc6!panda!genrad!decvax!tektronix!reed!psu-cs!omepd!mcg
References: <357@cullvax.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!rutgers!husc6!panda!genrad!decvax!tektronix!reed!psu-cs!omepd!mcg
From: mcg@omepd.UUCP
Newsgroups: net.lang.c
Subject: Re: Disappearing function call
Message-ID: <162@omepd>
Date: Sun, 12-Oct-86 18:22:57 EDT
Article-I.D.: omepd.162
Posted: Sun Oct 12 18:22:57 1986
Date-Received: Tue, 14-Oct-86 05:21:24 EDT
References: <357@cullvax.UUCP>
Reply-To: mcg@omepd.UUCP (Steven McGeady)
Organization: Intel Corp. Hillsboro, Oregon
Lines: 29
Summary: you're thinking too hard