I have a Qt application that is made in Visual Studio 2005 which uses a fair amount of other libraries which are all compiled with a struct member alignment of 1. I'm also pretty sure that Qt default uses a struct member alignment of 0.
This obviously causes issues when i compile my application with a struct member alignment of 0 (Other libraries will fail) or 1(Qt will fail).
I added the following at the top of the projects.pro file
QMAKE_CXXFLAGS_DEBUG += -Zp1 QMAKE_CXXFLAGS_RELEASE += -Zp1
I used the visual studio commandline to start the configure.exe which creates the makefiles.
This causes Qt to compile with a struct member alignment of 0. Maybe -Zp1 (I also tried /Zp1) is not recognized by the compiler but this would surprise me because this is how Visual Studio uses it in its property pages:
Now is was looking into doing about the same:
At this point I have the makefile which I can alter so that it can use a struct member alignment of 1. No success here.
How can i compile Qt for Visual Studio 2005 with a struct member alignment of 1?
Qt does not support a struct member aligment different from 8 (Default). The only way to solve this is by using #pragma pack
:
#pragma pack( [ show ] | [ push | pop ] [, identifier ] , n )
Surround all Qt code and includes with a push and pop:
#pragma pack(push, 8)
...
#pragma pack(pop)