use a string defined macro in *.pro file
-
wrote on 26 Apr 2019, 01:26 last edited by Limer
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)
-
@Limer I don't see any of your APP_* defines being passed to the compiler.
Did you actually rerun qmake after changing pro file? -
@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.
-
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)
@Limer please show the compile output
-
@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.
wrote on 26 Apr 2019, 05:03 last edited by Limer@dheerendra Had updated this post.
-
@Limer Can you show the 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 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? -
@Limer I don't see any of your APP_* defines being passed to the compiler.
Did you actually rerun qmake after changing pro file?
1/11