QMAKE DEFINES in Application
Solved
General and Desktop
-
Hello, Everyone
I`m try use QMAKE DEFINES in cpp source.
I put this values into my .pro fileVERSION = 1.0.1.2 DEFINES += VERSION=\\\"$$VERSION\\\"
And read in cpp source
QString version(VERSION); qDebug() << "Version" << version;
But when I compile with MSVC 2013 I have this error
****\main.cpp:8: error: C2065: 'VERSION' : undeclared identifier
How I can read DEFINE from *.pro file?
-
Hi! MSVC and gcc use different syntax for constants on the command line. The following should work (can't test it right now):
VERSION = 1.0.1.2 unix:DEFINES += VERSION=\\\"$$VERSION\\\" win32:DEFINES += VERSION=\"$$VERSION\"
EDIT: There have to be DOUBLE DOLLAR SIGNS. The forum software won't let me type this correctly. :-/
-
Ok,
I test it. And...... It isnt workI`m change
VERSION = 1.0.1.2 DEFINES += VERSION=\\\"$$VERSION\\\"
to
unix:DEFINES += VERSION=\\\"$$VERSION\\\" win32:DEFINES += VERSION=\"$$VERSION\"
And I have error:
****\main.cpp:8: error: C2065: 'VERSION' : undeclared identifier
-
Really? Just to be sure: Please clean your project and rebuild it.
-
Clean project
And have new error****\main.cpp:8: error: C2143: syntax error : missing ')' before 'constant' ****\main.cpp:8: error: C2664: 'QString::QString(QStringDataPtr)' : cannot convert argument 1 from 'double' to 'const QChar *' ****\main.cpp:8: error: C2059: syntax error : ')'
EDIT:
Now I add new macro#define _TOSTR(x) #x #define TOSTR(X) _TOSTR(X)
And now I can use DEFINES from *.pro file