'struct' size problem

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

'struct' size problem

跳至解决方案
795 次查看
sebasira
Senior Contributor I

Hello!

I'm used to work with structures, my whole application is based on them. Now I'm porting this 'old' app from HCS12 to K60... It's a HUGE change but it is not far for being over.

I've got a structure defined like this:

typedef struct{

      word mov;

      byte addressRx;

      byte addressTx;

      byte tipoReloj;

      byte empty[3];        // 3 empty bytes so the whole size is 4bytes-aligned

}tPARAM;

The problem is that every parameter inside this structure has a size of 4bytes instead of 2bytes for 'word' and 1byte for 'byte'. In HCS12 wich is a 16bit MCU I don't have this problem but I do in K60 wich is 32bits.


What can I do so the size of each parameter would be as expected?


Thanks in advance!!!

Best Regards,


SebaS

标签 (1)
0 项奖励
回复
1 解答
648 次查看
sebasira
Senior Contributor I

My bad!

Not every parameter has 4byte size, but only the word one. The problem was that I declared word as unsigned int and I found out that others declare it as unsigned short.

Problem solved!!!!

在原帖中查看解决方案

0 项奖励
回复
1 回复
649 次查看
sebasira
Senior Contributor I

My bad!

Not every parameter has 4byte size, but only the word one. The problem was that I declared word as unsigned int and I found out that others declare it as unsigned short.

Problem solved!!!!

0 项奖励
回复