Re: One byte bool
Re: One byte bool
- Subject: Re: One byte bool
- From: Eric Albert <email@hidden>
- Date: Wed, 15 Mar 2006 10:05:52 -0800
On Mar 15, 2006, at 8:24 AM, Scott Fraser wrote:
Yes, a search of the Mac headers does reveal at least one "bool" in a
struct: "CGEventTapInformation". Using a "bool" as a function return
type or a function call parameter type isn't a problem, as all
integral arguments and return values get promoted to 32-bits in both
PPC and Intel calling conventions.
Actually, integral arguments and return values are not always promoted
to 32-bit values, particularly in optimized code. This isn't really an
issue for bool arguments because the callee always knows the type of
its arguments, but we've seen quite a few cases on Intel where calling
a function which returns bool or BOOL that doesn't have a prototype in
scope results in the wrong code path being executed because the
compiler defaults to 'int' or 'id' as an assumed return type for
functions without prototypes in scope and assumes that it can compare
32 bits to zero. When only the low bit (or, more typically, the low 8
bits) is explicitly set and the rest are uninitialized, this doesn't
work very well.
Those cases are app bugs, by the way, not compiler bugs. Fortunately
they're pretty unusual.
-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