The issue is likely that for the first bit field, the compiler "allocates" an object of the specified member type, which in your not-working example was an 8 bit int. It then fits successive bit field members in there until the object is full. Because your object only has 8 bits, the second member already does not fit; the compiler allocates a second char. Same for members 3 and 4, makes a 4 char = 32 bit struct. If you declare the members as 16 bit types, all bit fields fit into the first "allocated" object. The union should be superfluous (and, of course, was pointless before).
↧