Disappearing function call

Lawrence W. McVoy mcvoy at rsch.WISC.EDU
Mon Oct 27 16:38:48 AEST 1986


In article <162 at omepd> mcg at omepd.UUCP (Steven McGeady) writes:
>
>You guys are all thinking too hard.  
>
>	#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);

I came into this late, so you might already know this, but try this on for 
size anyway:

# ifdef		DEBUG
#   define	debug(x)	fprintf x
# else
#   define	debug(x)
# endif

.....

	debug((stderr, "Control string", arg1, arg2, ... argn));

Cute, isn't it?  I stole it out of the src to enscript (adobe something or
other).
-- 
Larry McVoy 	        mcvoy at rsch.wisc.edu, 
      		        {seismo, topaz, harvard, ihnp4, etc}!uwvax!mcvoy

"They're coming soon!  Quad-stated guru-gates!"



More information about the Comp.lang.c mailing list