Re: One byte bool
Re: One byte bool
- Subject: Re: One byte bool
- From: Damien Bobillot <email@hidden>
- Date: Tue, 14 Mar 2006 23:36:15 +0100
Mark Stultz wrote :
I'm in the process of converting our game library into Universal
Binaries
(fun!) I got everything up and built in about 30 minutes. I've
only ran
into issues due to structures using bool's (sigh). Of course, the
default
size is 4 bytes on PPC and 1 byte on x86.
The option...
"Use a size of 1 byte (instead of 4 bytes) for the 'bool' type.
[GCC_ONE_BYTE_BOOL, -mone-byte-bool]
Warning: this setting generates code that may not binary compatible
with
code generated without this setting or with Mac OS X frameworks."
...does exist. That warning scares me. As does that typo: "may
not binary
compatible". What real issues can I expect to encounter with this?
All "bool"s you may see in Mac OS X headers are supposed to be 4
bytes long, and the library code expect it. Il you change it to a 1
byte bool, you may have problem with structures as shown with the
following code :
#include <stdbool.h>
#include <stdio.h>
struct something { bool hello; bool hello2; };
int main() {
struct something aaa = {true, true};
fwrite(&aaa, sizeof(aaa), 1, stdout);
return 0;
}
If you compile it without -mone-byte-bool and run "a.out | hexdump"
on a ppc, you'll get :
0000000 0000 0001 0000 0001
If you use -mone-byte-bool, you'll get :
0000000 0101
The "something" structure is not the same....
Moving forward, I'm not opposed to using a uint8 instead of a
bool. Would that be
a better option?
I think it's a better solution.
--
Damien Bobillot
_______________________________________________
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