This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

struct: uvision describe char as short

I've one strange error. I define a struct with unsigned short and one unsigned char variable.

typedef struct struct1{
   unsigned short a;
   unsigned short b;
   unsigned char c;
   unsigned short d;
}MsStruct;

I initialize the whole struct with default values - for example c = 2 (where 2 is a define directive).

But if I take a look in the memory window I could see that the unsigned char variable c takes 4Bytes instead of 2Bytes! But what's the reason for the compiler or the program uvision to use 4Bytes for this car value???

I never changed the value for the unsigned char c variable - so it's always 2 (0x02) but not 0x0002 (as I can see it in the memory window when I debug with the controller )!

best wishes
Torben

0