Hello,
I am using the nRF52840 DK with Keil to develop. I have a structure defined as follows:
typedef struct { uint16 packetType; uint32 packetLength; uint32 uuid[2]; uint8 part; uint8 totalParts; //data here //... //uint16 crc } multipart_header;
I have verified that uint8 is 1 byte, uint16 is 2 bytes, and uint32 is 4 bytes. The size of struct multipart_header should be 16 bytes but it reports 20 bytes in the debugger. I can see what look like two shorts in the memory window, one after packetType and one after totalParts. Is Keil padding this structure to a 32-bit boundary? This is a problem for me because I am filling up this structure and then memcpy-ing it in to a buffer as a header. I am getting four garbage bytes into the buffer. How can I avoid this? Must I move each field into the buffer separately?
Thanks!