I was trying to find a reason why I should not write
struct bitfield { signed foo:4; unsigned bar:2; }; instead of specifying verbosely
struct bitfield { signed int foo:4; unsigned int bar:2; }; As the size of each member of the bitfield is explicitly specified after the colon, could there be any drawbacks?
Does it matter if I use char, short, long, long long? Must the number of specified bitfield bits probably always be smaller than the width of the declaration type?
Found some related questions:
- Bit-fields of type other than int?
- What is the use of declaring different datatypes inside bitfields?
The answers range from
- don't use any other type than (signed/unsigned)
intor_Booland _Bool,signed int,unsigned int, or some other implementation-defined type. (C99 6.2.7.1 (4) )
In this context: what may this unspecific some other implementation-defined type be like, and what other drawbacks may arise from my choice in this place?