Qt stop compiling giving windows.h error
-
My application was compiling correctly but suddenly, after minor code changes, it started to give this error.
In file included from C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/winbase.h:40:0,
from C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/windows.h:70,
from C:\Qt\5.12.12\mingw73_64\include/QtCore/qt_windows.h:64,
from C:\Qt\5.12.12\mingw73_64\include/QtGui/qopengl.h:49,
from C:\Qt\5.12.12\mingw73_64\include/QtQuick/qsggeometry.h:44,
from C:\Qt\5.12.12\mingw73_64\include/QtQuick/qsgnode.h:43,
from C:\Qt\5.12.12\mingw73_64\include/QtQuick/qsgrendererinterface.h:43,
from C:\Qt\5.12.12\mingw73_64\include/QtQuick/qquickwindow.h:44,
from C:\Qt\5.12.12\mingw73_64\include/QtQuick/qquickview.h:43,
from C:\Qt\5.12.12\mingw73_64\include/QtQuick/QQuickView:1,
from qtquick2applicationviewer\qtquick2applicationviewer.h:14,
from qtquick2applicationviewer\qtquick2applicationviewer.cpp:11:
C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/utilapiset.h:28:1: error: expected unqualified-id before '}' token
}
^I checked my code and i could not find anything strange. It seems something related to windows.h.
So i tried to create a new project from QtCreator. I created a Qt Quick application and i only add the inclusion of windows.h
#include <windows.h> #include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); }
and it is also giving this error
C:\Qt\Tools\mingw730_64\x86_64-w64-mingw32\include\utilapiset.h:28: error: expected unqualified-id before '}' token
In file included from C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/winbase.h:40:0,
from C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/windows.h:70,
from ..\ProvaWindows\main.cpp:1:
C:/Qt/Tools/mingw730_64/x86_64-w64-mingw32/include/utilapiset.h:28:1: error: expected unqualified-id before '}' token
}
^I can't understand why it suddendly stop compiling.
NOTE: I'm having this error using MinGW 7.3.0 64 bit, if i change compiler and for example i use the same MinGW 7.3.0 but 32 bit, i have no errors!
Please help!
Thanks -
Are you sure it every compiled with MinGW 7.3 with 64bits? I would guess no.
Try to compile a simple main.cpp without any Qt includes but <windows.h> and see if you get errors - if so I don't see what Qt can do against it. -
Are you sure it every compiled with MinGW 7.3 with 64bits? I would guess no.
Try to compile a simple main.cpp without any Qt includes but <windows.h> and see if you get errors - if so I don't see what Qt can do against it.@Christian-Ehrlicher Hi, thanks for your reply! I'm sure that i was compiling with MinGW 7.3 64bits, the application was running on my PC correctly. Then i add a class and did some changes, i tried to compile again and it gave the error. However, has you suggested, I created a c++ application (no Qt include) and i add the include of windows.h in the main.cpp. I have the same error.
-
So your installation is somewhat broken - no Qt problem.
-
So your installation is somewhat broken - no Qt problem.
@Christian-Ehrlicher yes, i found that the file utilapiset.h had something wrong inside it (i don't know how and who had modified it). I fixed it and not it works! Thanks!