Path: chuka.playstation.co.uk!news From: James Russell Newsgroups: scee.yaroze.beginners Subject: Re: Debugging code Date: Tue, 22 Sep 1998 09:27:29 +0100 Organization: Sony Computer Entertainment Europe Lines: 43 Message-ID: <36075F71.B9689F1F@scee.sony.co.uk> References: <36060A0C.97E@dma-design.com> <36061BEA.536E8D68@scee.sony.co.uk> <3606303C.869@dma-design.com> <3606A600.C79FE1FE@shell.jps.net> NNTP-Posting-Host: mailgate.scee.sony.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5b1 [en] (Win95; I) X-Accept-Language: en Elliott Lee wrote: > > You could add the following variable at the top of your code: > > #define SHOW_DEBUG_STUFF > > and whenever you want a debugging statement in your code just put: > > #ifdef SHOW_DEBUG_STUFF > printf( "DEBUG: Initializing Sound...\n" ); > #endif > 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); If "DEBUG" is not defined, that line isn't even included in the compile. The reason I do this is that it stops my code getting clogged up with lots if "#ifdef" and "#endif" lines. Cheers, James -- == James_Russell@scee.sony.co.uk +44 (171) 447-1626 == Developer Support Engineer - Sony Computer Entertainment Europe "Go to Red Alert." "Are you absolutely sure, sir? It'll mean changing the bulb."