typedef struct BaseMessage
{
int u32DeviceID : 32;
int u32CoreID : 32;
unsigned int u16Class : 16;
unsigned int u8OpCode : 8;
unsigned int u16CRC : 16;
} BaseMessage;
typedef struct MessageWithParameters
{
BaseMessage base;
int u8Param1 : 8;
int u8Param2 : 8;
} MessageWithParameters;
typedef struct FullMessage
{
int u32DeviceID : 32;
int u32CoreID : 32;
unsigned int u16Class : 16;
unsigned int u8OpCode : 8;
unsigned int u16CRC : 16;
int u8Param1 : 8;
int u8Param2 : 8;
} FullMessage;
int main()
{
printf("%d", sizeof(MessageWithParameters));
printf("%d", sizeof(FullMessage));
}
In MessageWithParameters
doesn't the BaseMessage
take some size by itself?
Even if it's on the stack?
I am guessing that the compiler turns MessageWithParameters
to something that looks like FullMessage
.
Am I correct?