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: Scott Ribe <email@hidden>
- Date: Tue, 09 Jul 2013 14:25:03 -0600
On Jul 9, 2013, at 12:56 PM, Jens Alfke wrote:
>
> On Jul 9, 2013, at 11:31 AM, Scott Ribe <email@hidden> wrote:
>
>> I don't see what @true/@false have to do with true/false.
>
> @true is a shortcut for @(true), so the compiler first evaluates ‘true’ and then boxes the result.
OK, true. (haha)
> I think the issue is that the auto-boxing code has a special case for the Obj-C YES/NO constants that outputs boolean-type NSNumbers instead of 0/1, but it doesn’t have the same special case for the C99 ‘bool’ type.
Yes, that seems like a bug. I don't see any reason why boxing of true/false should necessitate creating a boxed int.
> On Jul 9, 2013, at 02:48 , Jean-Daniel Dupas <email@hidden> wrote:
>
>> 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.
>
> In C99 ‘true’ and ‘false’ are builtin constants of type ‘bool’, not macros. (Right? IANALL.)
Well, technically, to be most flexible wrt to backwards compatbility, etc, bool is a macro (or typedef???) for _Bool, and true/false are macros, and there's a __bool_true_false_are_defined that allows you to write your own header to allow for code that is compatible with both C99 and older compilers. If you really care, open <stdbool.h>
--
Scott Ribe
email@hidden
http://www.elevated-dev.com/
(303) 722-0567 voice
_______________________________________________
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