2010/1/4 Greg Parker <gpar...@apple.com>:
> On Jan 2, 2010, at 9:30 AM, Alexander Spohr wrote:
>> I put a , not a ; between the statements. So at least my last example would 
>> work - had I just left the last ; out of it:
>>
>> #define GDRelease(x) [(x) release], (x) = nil
>> expands to:
>> if(x)
>>   [(x) release], (x) = nil;
>> else
>>   foo(x);
>>
>> But the while(0) looks not as fragile.
>
> The do..while form also prevents errors like this:
>
>    if (GDRelease(x))  { ... }
>    // this is nonsense
>
>    if ( do { [(x) release]; (x) = nil; } while (0) ) { ... }
>    // this expansion is a compile error: good
>
>    if ( [(x) release], (x) = nil ) { ... }
>    // but this expansion compiles successfully: bad
>

Easily fixed:

#define GDRelease(x) [(x) release], (x) = nil, (void)0
_______________________________________________

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 arch...@mail-archive.com

Reply via email to