Re: Why are BOOL and bool distinct types?
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