This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A bit field's length


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]