Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
2.2.0
-
f082f8b03dc751ca8b1f5432d830ef4abf7b736d
Description
When generating a Visual Studio project file from the Qt VS Tools -> Open Qt Project File (.pro)... the resulting build files are not working if MOC is involved and the .pro file has defines in it.
Simple line in a header that is included from moc_* file breaks the build:
QString string = QStringLiteral(VERSION);
Where VERSION is in project.pro:
VERSION_STRING = 1.2.3.4
DEFINES += VERSION=\\\"$$VERSION_STRING\\\"
After importing the .pro file this way, and trying to build, following errors are shown:
1> moc_mainwindow.cpp 1>c:\<project>\generatedfiles\debug\../../mainwindow.h(7): error C2017: illegal escape sequence 1>c:\<project>\generatedfiles\debug\../../mainwindow.h(7): error C2059: syntax error: 'constant' 1>c:\<project>\generatedfiles\debug\../../mainwindow.h(7): error C2065: 'Size': undeclared identifier 1>c:\<project>\generatedfiles\debug\../../mainwindow.h(7): error C2975: 'N': invalid template argument for 'QStaticStringData', expected compile-time constant expression 1>c:\<project>\generatedfiles\debug\../../mainwindow.h(7): error C2143: syntax error: missing ';' before '}' 1>c:\<project>\generatedfiles\debug\../../mainwindow.h(7): error C2059: syntax error: '}' 1>c:\<project>\generatedfiles\debug\../../mainwindow.h(7): error C2059: syntax error: 'return' 1>c:\<project>\generatedfiles\debug\../../mainwindow.h(7): fatal error C1004: unexpected end-of-file found
The compiler command to build mainwindow.cpp is as follows (/I commands are removed):
CL.exe /c /Zi /nologo /W3 /WX- /diagnostics:classic /MP /Od /Oy- /D _WINDOWS /D UNICODE /D _UNICODE /D WIN32 /D QT_DEPRECATED_WARNINGS /D "VERSION=\"1.2.3.4\"" /D QT_WIDGETS_LIB /D QT_GUI_LIB /D QT_CORE_LIB /Gm- /EHsc /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Gd /TP /wd4577 /wd4467 /analyze- /errorReport:prompt -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 main.cpp mainwindow.cpp
Whereas the compiler call for the moc_mainwindow.cpp is:
CL.exe /c /Zi /nologo /W3 /WX- /diagnostics:classic /MP /Od /Oy- /D UNICODE /D _UNICODE /D WIN32 /D QT_DEPRECATED_WARNINGS /D VERSION=\1.2.3.4\ /D QT_WIDGETS_LIB /D QT_GUI_LIB /D QT_CORE_LIB /Gm- /EHsc /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Gd /TP /wd4577 /wd4467 /analyze- /errorReport:prompt -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 .\GeneratedFiles\Debug\moc_mainwindow.cpp
So it seems that while the normal compiler commandline is properly escaped, the commandline passed to compiling moc_mainwindow call has had the quotes simply removed.
If the Visual Studio project file is generated directly with qmake from commandline, this issue is not present:
c:\<project>\qmake -tp vc