Application struct alignment not working correctly

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Application struct alignment not working correctly

782件の閲覧回数
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 返信

650件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

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

0 件の賞賛
返信