Re: Type of @true in Obj-C vs Obj-C++
Re: Type of @true in Obj-C vs Obj-C++
- Subject: Re: Type of @true in Obj-C vs Obj-C++
- From: Jean-Daniel Dupas <email@hidden>
- Date: Tue, 09 Jul 2013 11:48:28 +0200
Le 9 juil. 2013 à 09:29, Rick Mann <email@hidden> a écrit :
> Well, in tracking down a problem with Security.framework, I discovered something today. One of these things is not like the other, unless you're translating Objective-C++:
>
> {
> id cfTrue = (__bridge id) kCFBooleanTrue;
> id atTrue = @true;
> id atYes = @YES;
>
> NSLog(@"kCFBooleanTrue class: %@", NSStringFromClass([cfTrue class]));
> NSLog(@"@true class: %@", NSStringFromClass([atTrue class]));
> NSLog(@"@YES class: %@", NSStringFromClass([atYes class]));
> }
>
> In Objective-C:
>
> 2013-07-09 00:29:14.074 TestSec2[30025:c07] kCFBooleanTrue class: __NSCFBoolean
> 2013-07-09 00:29:14.075 TestSec2[30025:c07] @true class: __NSCFNumber
> 2013-07-09 00:29:14.075 TestSec2[30025:c07] @YES class: __NSCFBoolean
>
>
> In Objective-C++:
>
> 2013-07-09 00:25:49.040 TestSec2[29983:c07] kCFBooleanTrue class: __NSCFBoolean
> 2013-07-09 00:25:49.041 TestSec2[29983:c07] @true class: __NSCFBoolean
> 2013-07-09 00:25:49.041 TestSec2[29983:c07] @YES class: __NSCFBoolean
>
> Is there a switch to pass to clang to make it always treat true & @true the way it does in C++?
>
No, unless you redefine the true and false macros.
The C standard specifies that true and false are macro that expand to integer constant with value 1 and 0 respectively.
-- Jean-Daniel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden