Using ARM and RTX on MCB2300, I have the following struct defined from an extern file storage array:
typedef struct choreoEvent { U8 flags; U16 leftover; U8 disable; U16 cueid; U32 time; char name[6]; U32 circuit; char display[12]; } choreoEvent_t;
This is 32 bytes in storage, but sizeof is reporting it as 36 bytes, and trying to access name starts 2 bytes off.
Is it doing alignment on the U8's or something? I can't restructure it because it's being read form an external file stream. Anyone see what's happening?
sizeof() reporting wrong size of struct
That's a very common misconception. No, the size reported by sizeof is not wrong. It's exactly correct. What's wrong here is your expectation of what it should be reporting.
And no, reading data structures from outside your C program directly into a struct is not how you do it. You may believe that #pragma pack is the solution to your problem --- well, it's not, and that's because the problem is not the one you think it is. For the proper solution, look up "serialization".
http://www.keil.com/forum/18859/
http://www.keil.com/forum/docs/thread20238.asp