For me this piece of code was unexpected. I would previously in my naivity assume that members of a struct that a decleared in order was placed as,
| b1 | b2 | b3 | b4 |
first     second
but I think this snippet show that assumption to be false,
#include <assert.h>
#include <stdint.h>
typedef union {
    struct {
        uint16_t first;
        uint16_t second;
    };
    uint32_t id;
} uuid_t;
int
main(void)
{
    uuid_t uuid;
    uuid.id = 0x11112222;
    assert(uuid.first == 0x1111);
    assert(uuid.second == 0x2222);
}
With the correction,
typedef union {
    struct {
        uint16_t second;
        uint16_t first;
    };
    uint32_t id;
} uuid_t;
asserts will pass and that doesn't yet makes sense to me. Why is that?
 
    