Re: One byte bool
Re: One byte bool
- Subject: Re: One byte bool
- From: Brad Oliver <email@hidden>
- Date: Wed, 15 Mar 2006 11:36:35 -0700
I can't think of any system libraries off the top of my head which
contain bool APIs - Carbon, OpenGL, OpenAL and QuickTime are all
good,
for example. They all assume C89 for the API, so "bool" doesn't even
come into play. Audit the APIs for the libraries you use to be safe,
but I'd bet you're OK for the most part.
CoreGraphics has APIs that use bools. I'm not aware of any others,
though.
For the original poster, one other thing you can do is try to
selectively change the your codebase so that "bools" become something
else. The least-intrusive (and most compatible) way we found was to
do something like this:
#if MAC_PORT
bool8 valueThatNeedsToBe8bit;
#else
bool valueThatNeedsToBe8bit;
#endif
Then we had defined bool8 as a class in a header, like so:
class bool8
{
unsigned char mVal;
public:
bool8() {}
bool8(const bool inVal) { mVal = (unsigned char)inVal; }
bool8(const bool8& inVal) { mVal = inVal.mVal; }
bool8& operator= (const bool inVal) { mVal = (unsigned char)inVal;
return *this; }
bool8& operator= (const bool8 inVal) { mVal = inVal.mVal; return
*this; }
operator bool() const { return (bool)mVal; }
};
We made this change whenever we ran across structures that were read/
written to disk or shared over the net with PCs, which gave us
maximum compatibility with other platforms. Defining bool8 as a class
was necessary so that C++ methods with unique signatures that also
took, say, an unsigned char would be seen as unique - a #define bool
unsigned char would not have accomplished that.
All that said, the 1-byte bool option has been a dramatic help for us.
--
Brad Oliver
email@hidden
_______________________________________________
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