Disappearing function call

John Woods, Software john at frog.UUCP
Wed Oct 8 05:43:33 AEST 1986

> What I want to do is to write a function call of a variable number of
> arguments:
> 	debug(x, y, z, ...)
> that will generate no code when the symbol DEBUG is not defined, but
> generate a call of some function (say, debug_()) when it is.


#ifdef DEBUG
#define debug(x) x
#define debug(x)

	debug( puts("Shut 'er down, Scotty, she's sucking mud again."); )

The extra layer of indirection may feel irritating, but it also allows

	debug( if (op == NULL) exit(puts("RATS RATS RATS [#566, para. 1]")); )

It's quick, it's easy, it works.

John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, ...!mit-eddie!jfw, jfw%mit-ccc at MIT-XX.ARPA

"Don't give me this intelligent life crap,
just find me a planet I can blow up."

More information about the Comp.lang.c mailing list