• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: One byte bool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: One byte bool (From: Scott Fraser <email@hidden>)

  • Prev by Date: RE: GDB not stopping at breakpoints
  • Next by Date: Re: Xcode doesn't set executable bit for built executable
  • Previous by thread: Re: One byte bool
  • Next by thread: Re: One byte bool
  • Index(es):
    • Date
    • Thread