收录日期:2020/10/28 07:55:19 时间:2010-09-07 02:18:55 标签:windows-ce

I have built a test for a driver in Windows CE 6.0 and some tests fail because memory passed in is not properly aligned.

How can I control the alignment of auto variables on the stack (not inside structures)?

Keep in mind that I cannot change this test in any way except how I build it.

Automatic variables are automatically aligned according to their natural alignment, unless you explicitly tell the compiler not to do so. So, if you need an address with 4 byte alignment, declare a 4 byte variable, like a DWORD.

There is no error message, the problem is when an unsigned byte is declared on the stack, the address is not 4-byte aligned, and I need it to be.

The exe that is built is a conformance test and I cannot change the code. When I build for windows the stack vars are 4-byte aligned, but when I build for CE they are not aligned