Disappearing function call

Guido van Rossum guido at mcvax.uucp
Sat Oct 11 22:30:59 AEST 1986


In article <357 at cullvax.UUCP> drw at cullvax.UUCP (Dale Worley) writes:
>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.  If
>Is there a good way to do this?

If you are willing to write extra parentheses but want them to match,
write this:

	#ifdef DEBUG
	#define debug(x) debug_ x
	#else
	#define debug(x) /* empty */
	#endif

and call as follows:

	debug((x, y, z, ...));

-- 
	Guido van Rossum, CWI, Amsterdam <guido at mcvax.uucp>



More information about the Comp.lang.c mailing list