Re: bool, BOOL
Re: bool, BOOL
- Subject: Re: bool, BOOL
- From: "E. Wing" <email@hidden>
- Date: Tue, 29 May 2007 13:31:51 -0700
Is there any reason lowercase bool is not considered a keyword in .m files, while it
is in headers? Uppercase BOOL is colored in both types of files, but I prefer using
lower case.
I'm not sure about what the highlighting should do, but BOOL and _Bool
(and bool) are fundamentally different types and only BOOL is used by
the Cocoa frameworks. In objc.h BOOL is a typedef to signed char.
Using <stdbool.h>, bool is #define to _Bool which is the new "native"
boolean type for C99. C++ also has a native boolean type called bool.
If you switch to C++ or Obj-C++, you'll get the syntax highlighting
for bool (though this isn't advisable unless you are actually using
these languages).
Unfortunately, because BOOL is a signed char instead of a boolean
type, there are subtle differences. sizeof(BOOL)==1, but
sizeof(_Bool)==4 on PowerPC. @encode also must return different values
for BOOL and _Bool. I also learned that this has an unfortunate side
effect for language bridges to languages that support native boolean
types because an ambiguity is created where there didn't really need
to be one. I know that Lua is affected by this, and I've been told
Ruby has the same problem.
-Eric
_______________________________________________
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