Qt 5.10 tries to compile my precompiled headers as C instead of C++, obviously fails
-
Hi all,
I've got a Qt project created in Visual Studio, so it has this precompiled header file named "stdafx.h". Obviously I'm on Windows and using the MSVC compiler.
Now, everything worked fine before Qt 5.10, but now I started getting all kinds of weird errors which lead me to find a "-TC" compiler option in the makefile, that is supposed to force the compiler to treat a file as C instead of C++.
Qt 5.9.3 did not add this option, but the version 5.10 does for some reason - is there a way to disable it?
-
Hi and welcome to devnet,
What did you use to create the project ?
-
@hskoglund said in Qt 5.10 tries to compile my precompiled headers as C instead of C++, obviously fails:
Hi, not sure, but you could always try inserting
CONFIG += c++11
in your project's .pro file.
Didn't help.
-
@jsulm I just generated an empty Qt GUI project with precompiled headers using the current Visual Studio Tools, and it has exactly the same problem.
By the way it did not compile in VS2017 at all - did not even give any error messages.Then I exported it to a .pro file
# ---------------------------------------------------- # This file is generated by the Qt Visual Studio Tools. # ------------------------------------------------------ TEMPLATE = app TARGET = QtGuiApplication1 DESTDIR = ../x64/Debug QT += core widgets gui CONFIG += debug DEFINES += _UNICODE WIN64 QT_DLL QT_WIDGETS_LIB INCLUDEPATH += ./GeneratedFiles \ . \ ./GeneratedFiles/Debug PRECOMPILED_HEADER = stdafx.h DEPENDPATH += . MOC_DIR += ./GeneratedFiles/debug OBJECTS_DIR += debug UI_DIR += ./GeneratedFiles RCC_DIR += ./GeneratedFiles include(QtGuiApplication1.pri)
and tried compiling in the Qt Creator:
C:\Qt\Qt5.10.0\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
cl -c -Yc -Fpdebug\QtGuiApplication1_pch_c.pch -Fodebug\QtGuiApplication1_pch_c.obj -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zi -MDd -W3 -w44456 -w44457 -w44458 /Fddebug\QtGuiApplication1.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -D_UNICODE -DWIN64 -DQT_DLL -DQT_WIDGETS_LIB -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\QtGuiApplication1 -I. -I..\QtGuiApplication1\GeneratedFiles -I..\QtGuiApplication1 -I..\QtGuiApplication1\GeneratedFiles\Debug -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtWidgets -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtGui -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtANGLE -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore -IGeneratedFiles\debug -IGeneratedFiles -I\include -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\mkspecs\win32-msvc -TC ..\QtGuiApplication1\stdafx.h
stdafx.h
C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(53): error C2143: syntax error: missing '{' before '*'
C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(68): error C2061: syntax error: identifier 'Qt'
C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(68): error C2059: syntax error: ';'
C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(68): error C2449: found '{' at file scope (missing function header?)
C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(1760): error C2059: syntax error: '}'
C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(1793): error C2054: expected '(' to follow 'class'
C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(1793): error C2085: 'QInternal': not in formal parameter list
C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(1793): error C2143: syntax error: missing ';' before '{'
C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qsize.h(52): error C2054: expected '(' to follow 'class'
C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qsize.h(53): error C2085: 'QSize': not in formal parameter list
etc, etc...I dont get these errors if I rename the "stdafx.h" file to "stdafx.hpp", but that doesn't seem to be a valid answer to the problem.