A bit field's length
Ian Lance Taylor
iant@google.com
Wed Nov 21 16:02:00 GMT 2007
kum <a.kumaresh@gmail.com> writes:
> On a 32 bit platform,
> Is this structure legal?
>
> struct
> {
> UINT64 part1 : 48;
> UINT64 part2 : 16;
> }Parts;
gcc accepts that. It is not portable C--the C99 standard only
requires the compiler to support bitfields of type _Bool, int, or
unsigned int.
> Do I have to tune the compiler to pack them into a single 64 bit
> space?
No.
> While assigning some 32 bit value to Parts.part1, do I have to
> cast the r-value into UINT64?
No, the cast will happen automatically.
Ian
More information about the Gcc-help
mailing list