Disappearing function call
kenny at uiucdcsb.cs.uiuc.edu
kenny at uiucdcsb.cs.uiuc.edu
Sat Oct 4 00:49:00 AEST 1986
/* Written 12:44 pm Oct 2, 1986 by marcus at ihlpl.UUCP in uiucdcsb:net.lang.c */
>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,
[...]
>How about this:
>
>#ifndef DEBUG
>#define debug
>#endif
>
>and writing in the code:
>
> debug(a,b,c)
>
>If DEBUG is turned on, nothing will happen to the debug statements, so a
>call to debug will be produced (as you would expect). If DEBUG isn't
>defined, the symbol "debug" will be pre-processed out of existance, so
>the compiler will see an expression like:
>
> (a,b,c)
[...]
>Are there any problems with doing this? I suppose that some pre-processors
>could choke on the parenthesis after debug in the invocation, since debug
>is #defined as a parameter-less macro, but my pre-processor (SVR2) doesn't.
>
>Marcus Hall
/* End of text from uiucdcsb:net.lang.c */
If you invoke it in the code as
debug (a, b, c)
^ Note the space!
then no preprocessor should ever confuse it; macros with parameters are
recognized only if no space intervenes between the macro name and the
left parenthesis.
Kevin Kenny UUCP: {ihnp4,pur-ee,convex}!uiucdcs!kenny
University of Illinois at Urbana-Champaign CSNET: kenny at UIUC.CSNET
``Don't worry; I'm a New Yorker!'' ARPA: kenny at B.CS.UIUC.EDU (kenny at UIUC.ARPA)
More information about the Comp.lang.c
mailing list