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. use a string defined macro in *.pro file
Forum Update on Monday, May 27th 2025

use a string defined macro in *.pro file

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 3.1k Views
  • 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.
  • dheerendraD Offline
    dheerendraD Offline
    dheerendra
    Qt Champions 2022
    wrote on last edited by
    #2

    @Limer said in use a string defined macro in *.pro file:

    CURRENT_APP_VERSION

    You are doing the mistake in defined string. What you defined is CURRENT_VERSION. However printing the CURRENT_APP_VERSION.

    Dheerendra
    @Community Service
    Certified Qt Specialist
    http://www.pthinks.com

    LimerL 1 Reply Last reply
    4
    • LimerL Limer

      I want define a macro just like CURRENT_APP_VERSION, and let it to the the value 0.0.6 (beta), and then I can use it in main.cpp,

      // main.cpp
      ...
      
      int main()
      {
          qDebug() << CURRENT_APP_VERSION;
      }
      

      And I google it , found the solution in https://forum.qt.io/topic/68933/use-qmake-variable-in-cpp-file/3# , but after I wrote them(just as the below codes) , and then compiled it, qt-creator gives me an error CURRENT_APP_VERSION is not defined.

      # my.pro
      
      VERSION = 0.0.6
      
      DEFINES += CURRENT_APP_VERSION=\"\\\"$${VERSION}\\\"\"
      

      What's wrong? (QMake version 3.1 Using Qt version 5.10.1 in D:/Qt/5.10.1/msvc2015/lib in Windows 10)

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #3

      @Limer please show the compile output

      Qt has to stay free or it will die.

      LimerL 1 Reply Last reply
      0
      • dheerendraD dheerendra

        @Limer said in use a string defined macro in *.pro file:

        CURRENT_APP_VERSION

        You are doing the mistake in defined string. What you defined is CURRENT_VERSION. However printing the CURRENT_APP_VERSION.

        LimerL Offline
        LimerL Offline
        Limer
        wrote on last edited by Limer
        #4

        @dheerendra Had updated this post.

        1 Reply Last reply
        0
        • aha_1980A aha_1980

          @Limer please show the compile output

          LimerL Offline
          LimerL Offline
          Limer
          wrote on last edited by Limer
          #5

          @aha_1980

          D:\Test\src\main_window.cpp:32: error: C2065: “CURRENT_APP_VERSION”: 未声明的标识符
          
          jsulmJ 1 Reply Last reply
          0
          • LimerL Limer

            @aha_1980

            D:\Test\src\main_window.cpp:32: error: C2065: “CURRENT_APP_VERSION”: 未声明的标识符
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @Limer Can you show the compiler call?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            LimerL 1 Reply Last reply
            2
            • jsulmJ jsulm

              @Limer Can you show the compiler call?

              LimerL Offline
              LimerL Offline
              Limer
              wrote on last edited by
              #7

              @jsulm Sorry, What's meaning of compiler call?

              jsulmJ 1 Reply Last reply
              0
              • LimerL Limer

                @jsulm Sorry, What's meaning of compiler call?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @Limer Go to "Compile Ouput" tab in QtCreator, copy the build log there and paste it here. What we want to see is which parameters are passed to the compiler when it is called.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                LimerL 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @Limer Go to "Compile Ouput" tab in QtCreator, copy the build log there and paste it here. What we want to see is which parameters are passed to the compiler when it is called.

                  LimerL Offline
                  LimerL Offline
                  Limer
                  wrote on last edited by
                  #9

                  @jsulm 0_1556262284001_4E02986F-7219-42aa-9968-657E5BE10E9D.png

                  jsulmJ 1 Reply Last reply
                  0
                  • LimerL Limer

                    @jsulm 0_1556262284001_4E02986F-7219-42aa-9968-657E5BE10E9D.png

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @Limer I don't see any of your APP_* defines being passed to the compiler.
                    Did you actually rerun qmake after changing pro file?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    LimerL 1 Reply Last reply
                    4
                    • jsulmJ jsulm

                      @Limer I don't see any of your APP_* defines being passed to the compiler.
                      Did you actually rerun qmake after changing pro file?

                      LimerL Offline
                      LimerL Offline
                      Limer
                      wrote on last edited by
                      #11

                      @jsulm Ohhhhhhhhhhhhhh, solve it. After I delete the build-HaiwellClient-Desktop_Qt_5_10_1_MSVC2015_32bit-Release
                      directory, rebuild project, it success. Thanks a lot for your patient response.

                      1 Reply Last reply
                      1

                      • Login

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