Application struct alignment not working correctly

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

Application struct alignment not working correctly

492 Views
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.

Labels (1)
0 Kudos
1 Reply

360 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

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

0 Kudos