Path: chuka.playstation.co.uk!news From: Toby Hutton Newsgroups: scee.yaroze.beginners Subject: Re: Debugging code Date: 28 Sep 1998 14:36:46 +1000 Organization: PlayStation Net Yaroze (SCEE) Lines: 35 Sender: thutton@TECH10 Message-ID: References: <36060A0C.97E@dma-design.com> <36061BEA.536E8D68@scee.sony.co.uk> <3606303C.869@dma-design.com> <3606A600.C79FE1FE@shell.jps.net> <36075F71.B9689F1F@scee.sony.co.uk> NNTP-Posting-Host: 203.103.154.235 X-Newsreader: Gnus v5.3/Emacs 19.34 James Russell writes: > Just as an addendum which I find useful, I define 3 macros like so: > > #define DEBUG > > #ifdef DEBUG > #define debugStr(xxx) printf((xxx)) > #define debugStr2(xxx,yyy) printf((xxx),(yyy)) > #define debugStr3(xxx,yyy,zzz) printf((xxx),(yyy),(zzz)) > #else > #define debugStr(xxx) > #define debugStr2(xxx,yyy) > #define debugStr3(xxx,yyy,zzz) > #endif > > Then I can just go: > > debugStr2("The value of KillerBananaNum = %d\n",killerBananaNum); Or you could use: #if defined(DEBUG) #define dprintf(x) printf x #else #define dprintf(x) #endif and use it: dprintf(("foo = %d (0x%08x), bar = %d (0x%08x)\n", foo, foo, bar, bar)); Note the double parentheses. Means you can have just one macro. -- Toby.