Xref: utzoo comp.lang.c:28404 comp.unix.wizards:21776 alt.sources:1827 comp.sources.d:5252 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!haven!decuac!shlump.nac.dec.com!engage.enet.dec.com!oldtmr.enet.dec.com!wallace From: wallace@oldtmr.enet.dec.com (Ray Wallace) Newsgroups: comp.lang.c,comp.unix.wizards,alt.sources,comp.sources.d Subject: Re: #define DEBUG... (using printf for debugging) Message-ID: <1717@engage.enet.dec.com> Date: 3 May 90 20:22:25 GMT Sender: news@engage.enet.dec.com Followup-To: comp.lang.c Organization: Digital Equipment Corporation Lines: 29 In article <4247@tekfdi.FDI.TEK.COM>, wallyk@tekfdi.FDI.TEK.COM (Wally Kramer) writes... >In article <40628@cornell.UUCP> gordon@cs.cornell.edu (Jeffrey Adam Gordon) >writes: >>I want to have a DEBUG flag which controls whether diagnostic printfs >>are executed or not. > DEBUG (("informative message #1: j = %d, k = %d", j, k)); > /* note extra parens surrounding normal printf parameters */ Why not just do this - #define BITCH /* IE: don't print it */ #define DEBUG printf /* IE: do print it */ main( ) { BITCH( "What the <%s> is going on?\n", "hell" ); DEBUG( "%d - nothing.\n%d - something.\n", 1, 2 ); } When the "debug" macro is defined as nothing then the stuff in paranthesis gets eveluated as an expresion(s) but thats all. When the "debug" macro is defined as printf then your standard function call to printf occurs. There is no need for an extra set of parenthesis. --- Ray Wallace (INTERNET,UUCP) wallace@oldtmr.enet.dec.com (UUCP) ...!decwrl!oldtmr.enet!wallace (INTERNET) wallace%oldtmr.enet@decwrl.dec.com ---