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 (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]