Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Pre-Processor variable for Kits?
Forum Updated to NodeBB v4.3 + New Features

Pre-Processor variable for Kits?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CAD_codingC Offline
    CAD_codingC Offline
    CAD_coding
    wrote on last edited by
    #1

    Hi,
    I am using 2 kits for my project - one for MinGW 32 bit while the other for MinGW 64 bit.
    I have some code in a .cpp file which is used for either of them and I want to decide that using a pre-processor directive:

    @#ifdef(64bitKit)
    //64 bit code
    #else
    //32 bit code
    #endif@

    Also I want to use a similar mechanism for my .pro file.
    How can I do this?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stevenceuppens
      wrote on last edited by
      #2

      If your target is windows, you can use:

      #if defined(Q_OS_WIN64)
      ...

      #if defined(Q_OS_WIN32)
      ...

      Steven CEUPPENS
      Developer / Architect
      Mobile: +32 479 65 93 10

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andreyc
        wrote on last edited by
        #3

        For .pro files take a look "here":http://qt-project.org/faq/answer/how_can_i_detect_in_the_.pro_file_if_i_am_compiling_for_a_32_bit_or_a_64_bi#899

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          Alternatively you can do this in your Qt Create Project settings. Your project has two kits associated with it. Each kit build configuration has a qmake command line associated with it. You can add additional arguments to the qmake line to create pre-processor symbols you can use in your code. For example:
          @
          DEFINES+="BITNESS=32"
          @
          or
          @
          DEFINES+="BITNESS=64"
          @

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved