[cairo] Re: Using bit fields a bit more in cairo
nmiell at gmail.com
Wed Dec 20 16:42:33 PST 2006
On Wed, 20 Dec 2006 11:12:54 -0500, Jim Gettys wrote:
> I'd do a bit more homework on this topic before going the bitfield
> direction in API's, though in many ways, I agree with most of the points
> you've made.
> There are two places you can get bit (if you don't mind the pun):
> o wire protocols (probably not applicable to this circumstance), where
> you have to be careful about alignment and byte ordering.
> o differing compilers on the same system.
> Last I knew (maybe more recent C standards have "fixed" this), C did not
> define which bits get used to represent a bit field in a larger object.
> The issue is, if one compiler does it one way and another does it
> differently on the same platform, you can lose when code from different
> compilers get mixed (not all platforms only use gcc...).
> And I don't know if ABI conventions on platforms are clear on this
> If someone has data on the current state of C compilers cross platform,
> now is the time to speak up.
> - Jim
GCC has a "ms_struct" attribute which is described as controlling the
layout of packed structs and/or structs containing bitfields, so this is
likely to be an issue on Windows systems when mixing GCC and Visual C++
objects. GCC also has a -mms-bitfields option which can be used when
building on Windows.
More information about the cairo