• 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: Rob Petrovec <email@hidden>
  • Date: Sat, 26 Apr 2008 20:08:40 -0700


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 ( 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'.
This will generate a compile error/warning on newer compilers.


We do something like this on our project:

#ifdef __cplusplus
extern "C" {
#endif
#if DEBUG
void	 DebugPrint_(const char* file, int line, const char* fmt, ...)
	{
		/* printing code*/
	 }
#endif
#ifdef __cplusplus
extern "C" {
#endif

#if DEBUG
#define PRINT(fmt, args...) DebugPrint_(__FILE__, __LINE__, fmt, ##args)
#else
#define PRINT(fmt, args...) ((void)0)
#endif


No compile errors on old or new compilers.  Enjoy...
_______________________________________________

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


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: Problem with bindings to user defaults
  • Next by Date: Re: Problem with bindings to user defaults
  • Previous by thread: Re: NSLog() replacement for debugger output
  • Next by thread: Obj-C client and Java-RMI server
  • Index(es):
    • Date
    • Thread