Disappearing function call
Frank Adams
franka at mmintl.UUCP
Mon Oct 6 10:17:35 AEST 1986
In article <357 at cullvax.UUCP> drw at cullvax.UUCP 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.
Here's a possibility which is slightly ugly, as all the others are, but the
ugliness is in a different place. Write:
#ifdef DEBUG
#define debug(a) debug_ a
#else
#define debug(a)
#endif
Now, write your debug statements with an extra pair of parentheses:
debug((x, y, z, ...));
I'm not necessarily recommending this; it's just an idea.
Frank Adams ihnp4!philabs!pwa-b!mmintl!franka
Multimate International 52 Oakland Ave North E. Hartford, CT 06108
More information about the Comp.lang.c
mailing list