Q:

Can anyone help me our in understanding this particular example of union?

union {
    unsigned char raw[8];
    struct {
        uint8_t gz_method;
        uint8_t flag;
        uint32_t mtime;
        uint8_t xtra_flags_UNUSED;
        uint8_t os_flags_UNUSED;
    } PACKED formatted;
} header;

I am aware that the memory allocated by union is the maximum of its variables. but here is it that it allocates memory as that taken by the struct?

A:

The whole union will take 8 bytes, because that's the size of its largest member.
Actually, in this case, both members have the same number of bytes (8). So, there are two ways to access to data: directly byte by byte or field by field.

