Hello to all. There is a point that I can't understand.
a 0-BIT FIELD is a signal to the compiler to align the following bit field at the beginning of a storage unit if storage units are 8 bits long the compiler will allocate 4 bits for the a member , skip 4 bits to the next storage unit and then allocate 8 bits for b.If storage units are 16bit long the compiler will allocate 4 bits for a skip 12 bits and then allocate 8 bits for b.Code:struct s { unsigned int a: 4; unsigned int: 0; unsigned int b: 8; }
I can't understand the layout. Compiler will allocate 4 bits for the a member in the first case and skip the 4 bits to the next storage but we have 8bits long storage unit the remaining is padding? "skip 4 bits to the next storage unit" from where is these 4 bits? where come from?
In the second case from where we have 12 bits?
I am little confusing about how memory layout is organized when we are dealing with bit fields