struct an char arrays alignment in 56800E

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

struct an char arrays alignment in 56800E

2,037 Views
admin
Specialist II
I use 56f8366(56800E core). According to a manual for CodeWarrior for 56800E (Targeting_56800E, p. 125 and 126) structures are word aligned (or double word, if they contain any double word variables). Shouldn't that also mean that data inside the strucutres are word (dword) aligned? What I observed is (see comments):

struct booStruct{
int dummyInt;
char singleChar;
char charArray[10];
}

main()
{
struct booStruct structInstance;
char * charPtr;
char tempChar;
structInstance.singleChar = 0x12;
structInstance.charArray[0] = 0x34;
structInstance.charArray[1] = 0x56;
...
charPtr = &structInstance.charArray[0];
tempChar = *charPtr;
//ERROR after this line tempChar should be
//equal to 0x34, it is equal to 0x12. Moreover,
//according to debugger:
//- address of singleChar is 0x0300;
//- address of charArray[0] is 0x0300;
}
It's similiar with arrays of characters. Is that possible to align characters (not char arrays!) inside the struct to two-byte boundaries? Just to let pointers work correctly...
Labels (1)
Tags (1)
0 Kudos
Reply
1 Reply

675 Views
trytohelp
NXP Employee
NXP Employee
Hi,
 
We're very sorry for the delay.
If the problem is still open can I suggest you to log your request to the Freescale CRM system ?
Please use Freescale on line support web page.
  - Go to following URL: http://www.freescale.com/TechSupport
  - Click on Submit a Service Request. You will come to a login page.
  - You can submit your request through the web from there.
Thanks
Pascal
0 Kudos
Reply