Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to add preprocessor directive into .pro ?
Forum Updated to NodeBB v4.3 + New Features

How to add preprocessor directive into .pro ?

Scheduled Pinned Locked Moved Solved C++ Gurus
7 Posts 2 Posters 1.9k 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    Is there a way to add preprocessor directive into QT project ( x.pro) file?

    is used to comment out the line , hence

    ( and tick tack toe marks the line to do unwanted formatting here...)

    #define TEST

    wouldn't do much

    JonBJ 1 Reply Last reply
    0
    • A Anonymous_Banned275

      Is there a way to add preprocessor directive into QT project ( x.pro) file?

      is used to comment out the line , hence

      ( and tick tack toe marks the line to do unwanted formatting here...)

      #define TEST

      wouldn't do much

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @AnneRanch
      For "preprocessor directive", .pro files can have their own variables if that is what you have in mind via

      TEST = 1
      

      See https://stackoverflow.com/questions/7754218/qmake-how-to-add-and-use-a-variable-into-the-pro-file.

      A 1 Reply Last reply
      0
      • JonBJ JonB

        @AnneRanch
        For "preprocessor directive", .pro files can have their own variables if that is what you have in mind via

        TEST = 1
        

        See https://stackoverflow.com/questions/7754218/qmake-how-to-add-and-use-a-variable-into-the-pro-file.

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by Anonymous_Banned275
        #3

        @JonB Per doc , i tried this

        DEFINES += #define TEST_DEFINE

        no go

        Doc does not help - used their example....

        JonBJ 1 Reply Last reply
        0
        • A Anonymous_Banned275

          @JonB Per doc , i tried this

          DEFINES += #define TEST_DEFINE

          no go

          Doc does not help - used their example....

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @AnneRanch

          DEFINES += TEST_DEFINE
          

          should cause -DTEST_DEFINE to be added to compiler command line.
          https://doc.qt.io/qt-6/qmake-variable-reference.html#defines

          A 1 Reply Last reply
          1
          • JonBJ JonB

            @AnneRanch

            DEFINES += TEST_DEFINE
            

            should cause -DTEST_DEFINE to be added to compiler command line.
            https://doc.qt.io/qt-6/qmake-variable-reference.html#defines

            A Offline
            A Offline
            Anonymous_Banned275
            wrote on last edited by
            #5

            @JonB Could you kindly tell me WHERE in QT Creator I can read compiler options?

            JonBJ 1 Reply Last reply
            0
            • A Anonymous_Banned275

              @JonB Could you kindly tell me WHERE in QT Creator I can read compiler options?

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @AnneRanch
              I don't have Creator to hand. There will be somewhere in "Build" where it tells you what compiler options it uses.

              Even there you might not be shown what your DEFINES are set to/what it will pass to the compiler. I would run a compilation and look at the actual command line being executed which it shows in one of the tabs at the bottom, "Compile" or "Build" Output or similar. There I would expect/hope to see it actually passing -DTEST_DEFINE somewhere on the command line if your .pro has the DEFINES += TEST_DEFINE example.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Anonymous_Banned275
                wrote on last edited by
                #7

                SOLVED

                putting

                DEFINES += define DEBUG

                in main .pro file

                has same effect as putting in

                #define DEBUG

                here is a snippet of compiler output?

                clang++ -c -pipe -g -std=gnu++1z -Wall -Wextra -fPIC -D_REENTRANT **-Ddefine -DDEBUG** -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_BLUETOOTH_LIB -DQT_NETWORK_LIB -DQT_DBUS_LIB -DQT_CORE_LIB -I. -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include/QtWidgets -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include/QtGui -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include/QtBluetooth -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include/QtNetwork -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include/QtDBus 
                
                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