Results 1 to 5 of 5

Thread: macros for x86/x64 and debug/release?

  1. #1
    Join Date
    Jul 2012
    Posts
    247
    Thanks
    29
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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)

    Qt Code:
    1. #ifdef _WIN64
    2. str = "windows 64";
    3. #else
    4. str = "windows 32";
    5. #endif
    To copy to clipboard, switch view to plain text mode 

    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...

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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

  4. #4
    Join Date
    Jul 2012
    Posts
    247
    Thanks
    29
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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...

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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:
    Qt Code:
    1. CONFIG(debug, debug|release): DEFINES += YOUR_DEBUG_MACRO
    To copy to clipboard, switch view to plain text mode 
    and you will not have to worry about what macros might be set by default.

Similar Threads

  1. Replies: 1
    Last Post: 10th October 2012, 08:46
  2. Qt Creator How to set .pro file about debug and release
    By yycking in forum Qt Tools
    Replies: 2
    Last Post: 28th February 2011, 18:28
  3. Why not on release but debug
    By baray98 in forum Qt Programming
    Replies: 6
    Last Post: 10th August 2007, 09:08
  4. Debug macros in 64bit systems
    By mcostalba in forum Qt Programming
    Replies: 8
    Last Post: 2nd December 2006, 20:16
  5. Debug and Release
    By paranoid_android in forum Qt Programming
    Replies: 5
    Last Post: 18th November 2006, 13:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.