When defining global variables in such way:
After compiling, var1 is placed at the lower 8 bits of address 0x00, var2 is placed at the upper 8 bits of address 0x00, var3 is placed at the lower 8 bits of address 0x01, and varArray is located from the upper 8 bits of address 0x01.
If there's a structure pointer such as:
STRUCT_TEST *sPtr = (STRUCT_TEST *)varArray;
now sPtr->w8Data1 is actually the lower 8 bits of address 0x01, which is var3, but not varArray. The reason is that varArray is not aligned and a structure pointer is always a word pointer in DSC compiler. So I tried to find a flexible way to do the alignment without modifying linker file. I found there's a similar question in this community, and the answer is to define variables in such way:
byte varArray __attribute__((aligned(2)));
But it is NOT working at all in CW10.6 on 56F84xxx.
Is there a solution for this? I need the answer asap.