PDA

View Full Version : macros for x86/x64 and debug/release?



tuli
8th January 2013, 22:04
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)


#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... ;)

amleto
8th January 2013, 23:15
depends entirely on the c++ implementation (ie msvc/mingw/clang/Comeau/...). It has nothing to do with Qt.

ChrisW67
8th January 2013, 23:36
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

tuli
11th January 2013, 00:31
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...

ChrisW67
11th January 2013, 00:55
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:


CONFIG(debug, debug|release): DEFINES += YOUR_DEBUG_MACRO

and you will not have to worry about what macros might be set by default.