On 18/03/2007 15:51, Timo Sirainen wrote:
On Sat, 2007-03-17 at 01:39 +0100, Václav Haisman wrote: [...]
uint32_t flags:8; uint32_t uid_broken:1; uint32_t expunged:1; uint32_t pseudo:1;
Right, I didn't think of that. But that feels a bit ugly :) I don't think it saves much memory anyway, so I'll keep it as uint8_t flags.
I may be a bit of a novice at this sort of thing, but if you want bitfields, does it matter what you say? In theory at least, unsigned int x:1; is all you need, it'll take one bit of storage, there's no point specifying the size of the thing you want truncated to one bit, what you're asking for is precisely one bit to be used as an unsigned integer. By saying e.g. uint8 x:1; you're specifying the size twice, and perhaps it's not a surprise if you get errors trying to compile it: which is it to be, 8 bits or 1?
Cheers,
John.