9.5.2.1 PIC32A Example
For example:
struct foo {
long long i:40;
int j:16;
char k:8;
} x;
struct bar {
long long I:40;
char J:8;
int K:16;
} y;
struct foo will have a size of 8 bytes using the
compiler. i will be allocated at bit offset 0 (through 39). No padding
is required before j, allocated at bit offset 40 since
j can be fully allocated without crossing an integer boundary at
bit offset 64. k will be allocated at bit offset 56 as it can fit
without crossing a boundary. The structure does not require extra padding to maintain
alignment in an array.
struct bar will have a size of 8 bytes using the
compiler. I will be allocated at bit offset 0 (through 39). There is no
need to pad before J because it will not cross a storage boundary for a
char. J is allocated at bit offset 40.
K can be allocated starting at bit offset 48, completing the
structure.
For this architecture, struct foo and struct bar have
the same size.
Unnamed bitfields may be declared to pad out unused space between active bits in control registers. For example:
struct foo {
unsigned int lo : 1;
unsigned int : 6;
unsigned int hi : 1;
} x;
