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
ok I think I get the problem -> data alignment - the compiler will store the following short variable d at a right position for a short variable -> so I've to install either to char variables back-to-back or change the variable to short.
torben
Compilers usually have an option or pragma or something to override the normal alignment requirements and "pack" objects together...