Here is the structure I want:
typedef struct someip_header { 
    union { 
        uint32_t message_id;
        struct {
            uint16_t service_id; 
            uint8_t for_rpc : 1; 
            union {
                uint16_t method_id : 15;
                uint16_t event_id : 15;
            };
        };
    };
} someip_header_t;
(The reason is that if for_rpc is 1, then the last 15 bits mean event ID, otherwise they mean method ID)
But the size of this structure is 5 bytes (packed), I guess because the compiler won't put union unaligned. If I replace the inner union with just a uint16_t val : 15, the size gets back to 4 bytes as expected:
typedef struct someip_header { 
    union { 
        uint32_t message_id;
        struct {
            uint16_t service_id; 
            uint8_t for_rpc : 1; 
            uint16_t method_event_id : 15;
        };
    };
} someip_header_t;
Just wondering, is there a way to pack this? It's really only cosmetic, but still...
 
    