Solved use a string defined macro in *.pro file
-
I want define a macro just like
CURRENT_APP_VERSION
, and let it to the the value0.0.6 (beta)
, and then I can use it inmain.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)
-
@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. -
@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.
-
@Limer please show the compile output
-
@dheerendra Had updated this post.
-
D:\Test\src\main_window.cpp:32: error: C2065: “CURRENT_APP_VERSION”: 未声明的标识符
-
@Limer Can you show the compiler call?
-
@jsulm Sorry, What's meaning of
compiler call
? -
@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.
-
-
@Limer I don't see any of your APP_* defines being passed to the compiler.
Did you actually rerun qmake after changing pro file? -
@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.