Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!caip!clyde!cbatt!ihnp4!inuxc!pur-ee!uiucdcs!uiucdcsb!kenny From: kenny@uiucdcsb.cs.uiuc.edu Newsgroups: net.lang.c Subject: Re: Disappearing function call Message-ID: <139200038@uiucdcsb> Date: Fri, 3-Oct-86 10:49:00 EDT Article-I.D.: uiucdcsb.139200038 Posted: Fri Oct 3 10:49:00 1986 Date-Received: Tue, 7-Oct-86 19:06:39 EDT References: <357@cullvax.UUCP> Lines: 46 Nf-ID: #R:cullvax.UUCP:357:uiucdcsb:139200038:000:1458 Nf-From: uiucdcsb.cs.uiuc.edu!kenny Oct 3 09:49:00 1986 /* Written 12:44 pm Oct 2, 1986 by marcus@ihlpl.UUCP in uiucdcsb:net.lang.c */ >In article <357@cullvax.UUCP> drw@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@UIUC.CSNET ``Don't worry; I'm a New Yorker!'' ARPA: kenny@B.CS.UIUC.EDU (kenny@UIUC.ARPA)