• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSLog() replacement for debugger output
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSLog() replacement for debugger output


  • Subject: Re: NSLog() replacement for debugger output
  • From: "Herb Petschauer" <email@hidden>
  • Date: Thu, 24 Apr 2008 18:26:10 -0700

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
<http://c-faq.com/cpp/multistmt.html> which really doesn't apply in
this example.

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.

Cheers,
-H.

On 24/04/2008, Ken Thomases <email@hidden> 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 ( TRUE == someCondition )
> >    DBOut( @"someCondition happened" );
> >
>
>  The above is fine.  It expands to:
>
>  if ( TRUE == someCondition )
>     ;
>
>  Note the semicolon.  It's an empty statement and serves as the body of the
> 'if'.  The following statement would not be sucked up to become part of the
> 'if'.
>
>
> >
> > [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 (no
> > reason to space the #define out like I've done if you don't want to).
> >
>
>  The above probably doesn't hurt, but it's overkill.  (On some compilers,
> which are probably not relevant, do-while-false is not well optimized.  Or
> so I've read.)
>
>  Cheers,
>  Ken
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSLog() replacement for debugger output
      • From: "Michael Ash" <email@hidden>
References: 
 >NSLog() replacement for debugger output (From: Don Arnel <email@hidden>)
 >Re: NSLog() replacement for debugger output (From: Mohsan Khan <email@hidden>)
 >Re: NSLog() replacement for debugger output (From: Mohsan Khan <email@hidden>)
 >Re: NSLog() replacement for debugger output (From: Don Arnel <email@hidden>)
 >Re: NSLog() replacement for debugger output (From: "Herb Petschauer" <email@hidden>)
 >Re: NSLog() replacement for debugger output (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Connecting streams together
  • Next by Date: Re: QTMovie grabing while playback
  • Previous by thread: Re: NSLog() replacement for debugger output
  • Next by thread: Re: NSLog() replacement for debugger output
  • Index(es):
    • Date
    • Thread