Hello Stan,
thanks for the answer.
I´m trying to read data from an external flash memory and process it (for example, reading the master boot record of a FAT filesystem). As I read an array of bytes (let´s call it byArr[512]) without padding bytes but my structure has padding bytes I cannot simply cast the byte array to my struct and expect that each field is located where it should.
For example, I read the 512 bytes of the master boot record of the FAT, and try to cast this byte array to the structure:
typedef struct _MasterBoot_Entries
{
UINT8 ExcecutableCode[446];
Partition_Entries Partitions[4];
UINT16 MBRSignature;
}MasterBoot_Entries;
It happens that ((MasterBoot_Entries *)byArr)->MBRSignature does not match the real value, which is *((UINT16 *)&byArr[510]).
It happens the same with all the fields in each ((MasterBoot_Entries *)byArr)->Partitions[x], as ((MasterBoot_Entries *)byArr)->Partitions is dword aligned, with padding byte before it
Am I missing something?
Regards