Application struct alignment not working correctly

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

Application struct alignment not working correctly

720 次查看
dan_quist
Contributor III

Hi,

 

I have an application I'm building that includes libraries from several other projects.

 

I have all the projects set to use coldfire struct alignment, but it only seems to work for the library projects and not the main project.

 

For example, in my main() function I create a new class object and the sizeof() will return 2256 bytes. Then I create an instance of the exact same type from code that is linked from another project and it returns 2286.

 

If I look at the memory layout of the two structures, it is very easy to see that one shows up as byte aligned while the other is not. If I set all the projects to use single byte alignment then everything matches, but I don't want to use single byte alignment. I want to use word aligntment.

 

Any suggestions on how I can force word alignment on my project?

 

Edit: I look at the disassembler and the sizeof() operator compiles to two different numbers for the same depending on which project it's compiled from.

标签 (1)
0 项奖励
回复
1 回复

588 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

can you please upload your demo code in zip thus we can check it directly here?

0 项奖励
回复