macros for x86/x64 and debug/release?
Hello,
VS provides macros which can be used by the preprocessor to def/undef parts of the source.
particulary:
_DEBUG - defined in debug builds
_M_IX86 - defined when builidng for x86
_M_X64 - defined when building for x64 (also: _WIN64)
Code:
#ifdef _WIN64
str = "windows 64";
#else
str = "windows 32";
#endif
Does Qt provide standardized macros for this?
Right now i am building for windows x86/x64 in visual studio and i heavily use above macros (esp. _WIN64).
Now a Linux/osx port starts to show up on the horizon and i start worrying... ;)
Re: macros for x86/x64 and debug/release?
depends entirely on the c++ implementation (ie msvc/mingw/clang/Comeau/...). It has nothing to do with Qt.
Re: macros for x86/x64 and debug/release?
See the Q_OS_* (and Q_WS_*) macros for some of this. As far as I know there is no documented macro to distinguish between a 32-bit or 64-bit Qt library: there should be no difference from a Qt client code perspective. There does seem to be a Q_OS_WIN64 in qglobal.h though.
If/when you need to distinguish between a range of compilers/architecture this can be useful: http://sourceforge.net/p/predef/wiki/Home/
QSysInfo can be useful at runtime
Re: macros for x86/x64 and debug/release?
Thanks for that link, very helpful.
I see your point that we, from a qt point of view, dont have to distinguish between x86/x64, but what about Release/Debug builds?
Dont you guys have stuff like
#ifdef _DEBUG
...extra debugging stuff goes here...
#endif
?
The projekts i work with are full of this...
Re: macros for x86/x64 and debug/release?
By default QT_NO_DEBUG is set for release builds and this is used to switch off range checks in QList for example. If you want something independent then in your PRO file:
Code:
CONFIG(debug, debug|release): DEFINES += YOUR_DEBUG_MACRO
and you will not have to worry about what macros might be set by default.