• 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: Why are BOOL and bool distinct types?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why are BOOL and bool distinct types?


  • Subject: Re: Why are BOOL and bool distinct types?
  • From: Alastair Houghton <email@hidden>
  • Date: Wed, 8 Jun 2005 11:34:35 -0700

On 8 Jun 2005, at 07:54, Todd Blanchard wrote:

On Jun 8, 2005, at 7:33 AM, Fritz Anderson wrote:
 bool is 32 bits on ppc and 8 bits on i386.

Not always, as others have pointed out.

On 8 Jun 2005, at 07:54, Todd Blanchard wrote:

That sounds like a fairly stupid decision by the compiler writers.

Says who?

The reason that 32-bits are often used for bool is that it provides significantly better performance on some architectures, and doesn't stuff-up the alignment in structures. So actually, it's a clever decision by compiler writers to get the best performance from the code; it's just that you don't understand why they did it.

It's also worth pointing out that the situation w.r.t. bool is exactly the same as the situation as regards the size of e.g. int or even char.

The reason that types like BOOL are (unfortunately) required is to create a stable ABI (and one that works across different compilers—e.g. IBM's compiler or CodeWarrior), since the size of a bool is an implementation detail, and compiler vendors are free to select an appropriate size at will (within the restrictions set by the relevant standards). It might be nice to have one or two standardised fixed-size bool types in addition to the existing one (ala the integer types in <stdint.h>), but it really isn't a new problem.

Kind regards,

Alastair.

--
www.alastairs-place.net


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Why are BOOL and bool distinct types? (From: Todd Blanchard <email@hidden>)
 >Re: Why are BOOL and bool distinct types? (From: "Sean McBride" <email@hidden>)
 >Re: Why are BOOL and bool distinct types? (From: Fritz Anderson <email@hidden>)
 >Re: Why are BOOL and bool distinct types? (From: Todd Blanchard <email@hidden>)

  • Prev by Date: Re: PyObjC on Intel
  • Next by Date: NSPopUpButtonCell trouble
  • Previous by thread: Re: Why are BOOL and bool distinct types?
  • Next by thread: Re: Why are BOOL and bool distinct types?
  • Index(es):
    • Date
    • Thread