Re: NSLog() replacement for debugger output

2008-04-26 Thread Rob Petrovec
On Apr 24, 2008, at 4:54 PM, Ken Thomases wrote: The do-while-false pattern is only necessary if you've got multiple statements or are otherwise surrounding the statements with braces. On Apr 24, 2008, at 5:43 PM, Herb Petschauer wrote: What happens in a release build in this situation? if

Re: NSLog() replacement for debugger output

2008-04-24 Thread Herb Petschauer
On 24/04/2008, Michael Ash <[EMAIL PROTECTED]> wrote: > > Ah well, I know I've been burned by this but it may have just been a > > by product of using it for a different kind of macro under a different > > compiler. > > > It's only useful for multi-statement macros. The idea is that a macro >

Re: NSLog() replacement for debugger output

2008-04-24 Thread Michael Ash
On Thu, Apr 24, 2008 at 11:57 PM, Jens Alfke <[EMAIL PROTECTED]> wrote: > > On 24 Apr '08, at 8:09 PM, Michael Ash wrote: > > > > It's only useful for multi-statement macros. > > > > And macros that use an 'if': > > extern BOOL gVerboseMode; > #define LOG(X) if(gVerboseMode) NSLog(@"value = %i

Re: NSLog() replacement for debugger output

2008-04-24 Thread Jens Alfke
On 24 Apr '08, at 8:09 PM, Michael Ash wrote: It's only useful for multi-statement macros. And macros that use an 'if': extern BOOL gVerboseMode; #define LOG(X) if(gVerboseMode) NSLog(@"value = %i",X); ... if( a > 5 ) FOO(a); else a = 5; won't do what you expect, because

Re: NSLog() replacement for debugger output

2008-04-24 Thread Michael Ash
On Thu, Apr 24, 2008 at 9:26 PM, Herb Petschauer <[EMAIL PROTECTED]> wrote: > Yes, good point. I _thought_ there was a good example of why to use > the while false pattern but it's so far back in time that I can't > recall it. The only thing that I can find is >

Re: NSLog() replacement for debugger output

2008-04-24 Thread Herb Petschauer
Yes, good point. I _thought_ there was a good example of why to use the while false pattern but it's so far back in time that I can't recall it. The only thing that I can find is which really doesn't apply in this example. Ah well, I know I've been burned by

Re: NSLog() replacement for debugger output

2008-04-24 Thread Ken Thomases
The do-while-false pattern is only necessary if you've got multiple statements or are otherwise surrounding the statements with braces. On Apr 24, 2008, at 5:43 PM, Herb Petschauer wrote: What happens in a release build in this situation? if ( TRUE == someCondition ) DBOut( @"someConditio

Re: NSLog() replacement for debugger output

2008-04-24 Thread Herb Petschauer
What happens in a release build in this situation? if ( TRUE == someCondition ) DBOut( @"someCondition happened" ); [foo someMethod]; I'd recommend the #define DBOut(fmt, ...)\ do\ {\ fprintf(etc);\ }\ while ( false ) pattern lest you get different results in DEBUG vs non DEBUG code (

Re: NSLog() replacement for debugger output

2008-04-24 Thread Don Arnel
Good point! I've only used it with arguments so far. Here is a better version: #ifdef __DEBUG_OUT__ #define DBOut(fmt, ...) fprintf(stderr, "%s\n", [[NSString stringWithFormat:(fmt), ## __VA_ARGS__] cStringUsingEncoding:NSUTF8StringEncoding]) #define DBCOut(fmt, ...) fprintf(stderr, fmt

Re: NSLog() replacement for debugger output

2008-04-24 Thread Don Arnel
If you cut and pasted the code make sure each line begins with the # character. If not then your mail reader wrapped a long line onto the next line. On Apr 24, 2008, at 6:20 PM, Mohsan Khan wrote: Sorry, I was a little bit to quick there... I get an error 169: DBOut( @"Hello World!" ); /

Re: NSLog() replacement for debugger output

2008-04-24 Thread Ken Thomases
There should be two hash characters ("##") before the __VA_ARGS__. That's a gcc feature such that, if the macro is used without passing arguments beyond the format string, then the comma is removed from the expansion. -Ken On Apr 24, 2008, at 5:20 PM, Mohsan Khan wrote: Sorry, I was a l

Re: NSLog() replacement for debugger output

2008-04-24 Thread Mohsan Khan
Sorry, I was a little bit to quick there... I get an error 169: DBOut( @"Hello World!" ); /AppController.m:169: error: syntax error before ']' token Did I miss something? On to 24 apr 2008, at 23.24, Mohsan Khan wrote: Ohh this is so good, I'm happy!!! Thanks! On to 24 apr 2008, at 21

Re: NSLog() replacement for debugger output

2008-04-24 Thread Mohsan Khan
Ohh this is so good, I'm happy!!! Thanks! On to 24 apr 2008, at 21.53, Don Arnel wrote: I thought I'd share this with those of you who want an alternative to NSLog(). If you want your debugging output to always go to the debugger console without all the date and time stamping info, just

NSLog() replacement for debugger output

2008-04-24 Thread Don Arnel
I thought I'd share this with those of you who want an alternative to NSLog(). If you want your debugging output to always go to the debugger console without all the date and time stamping info, just place this bit of code in your _Prefix.pch file. Then define the __DEBUG_OUT__ preprocessor