5 years ago.

The size of a struct

I have a struct as given, When I get the sizeof the struct with the code, I get 16 Bytes. printf("\nSize of PACKHEADER, %d", sizeof(PACKHEADER));

I am using LPC1768 microcontroller.

Why doesn't it give 14 Bytes? struct PACKHEADER { uint8_t b; uint8_t m; int32_t fsize; int32_t reserved; int32_t ofset; };

1 Answer

5 years ago.

Hi there, probably Data structure alignment

https://stackoverflow.com/questions/119123/why-isnt-sizeof-for-a-struct-equal-to-the-sum-of-sizeof-of-each-member

Best regards

J.

Accepted Answer