AnsweredAssumed Answered

Application struct alignment not working correctly

Question asked by Dan Quist on Jun 27, 2013
Latest reply on Jun 27, 2013 by ZhangJennie

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.

Outcomes