Xref: utzoo comp.lang.c:28499 comp.unix.wizards:21834 alt.sources:1846 comp.sources.d:5288 misc.misc:9677 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!romp!auschs!awdprime!commlab1!tif From: tif@commlab1..austin.ibm.com (/32767) Newsgroups: comp.lang.c,comp.unix.wizards,alt.sources,comp.sources.d,misc.misc Subject: Re: #define DEBUG... (using printf for debugging) Message-ID: <2294@awdprime.UUCP> Date: 4 May 90 18:14:26 GMT References: <11290@hoptoad.uucp> <40628@cornell.UUCP> Sender: jroot@awdprime.UUCP Reply-To: tif@awdprime.austin.ibm.com.UUCP (/32767) Followup-To: comp.lang.c Organization: IBM AWD, Austin, TX Lines: 23 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 ("debugging information"); >but then how do I turn DEBUG off? Actually it's easier than you thought: #define DEBUG will turn it off although the string will still be put in your executable (unless your optimizer is better than mine). ("xx") is a parenthesised pointer expression which is a valid C statement. Most people I know of do #define DEBUG(xx) printf xx and then DEBUG(("the flag is %d\n", flag)); The whole thing is completely removed with #define DEBUG(xx) Paul Chamberlain tif@doorstop.austin.ibm.com tif@commlab1.austin.ibm.com sc30661@ausvm6