struct an char arrays alignment in 56800E

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

struct an char arrays alignment in 56800E

2,031 次查看
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...
标签 (1)
标记 (1)
0 项奖励
回复
1 回复

669 次查看
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 项奖励
回复