A lot of Warnings ONLY on MingW compiler
Unsolved
General and Desktop
-
I'm developing a cross-platform Qt C++ project.
I compile it in different systems and compilers without any warning or error.
The only system that gives me a different output is:- Windows 10 x64 using MingW 8.1 (that comes with Qt 5.15.1 installer)
In this specific setup I got 10.100 warnings.
Most of them are repeated, but I will paste here some examples:C:\Qt\5.15.1\mingw81_64\include\QtCore\qobjectdefs.h:114: warning: optimization attribute on 'constexpr const QMetaObject* qt_getEnumMetaObject(QMessageBox::Icon)' follows definition but the attribute doesn't match [-Wattributes] In file included from C:\Qt\5.15.1\mingw81_64\include/QtGui/qwindowdefs.h:44, from C:\Qt\5.15.1\mingw81_64\include/QtWidgets/qwidget.h:44, from C:\Qt\5.15.1\mingw81_64\include\QtWidgets/qmainwindow.h:44, from C:\Qt\5.15.1\mingw81_64\include\QtWidgets/QMainWindow:1, from ..\..\rotortest\App\app.h:4, from ..\..\rotortest\App\main.cpp:1: C:\Qt\5.15.1\mingw81_64\include/QtCore/qobjectdefs.h:114:75: warning: optimization attribute on 'constexpr const QMetaObject* qt_getEnumMetaObject(QMessageBox::Icon)' follows definition but the attribute doesn't match [-Wattributes] friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ ^~~~~~~~ C:\Qt\5.15.1\mingw81_64\include/QtCore/qobjectdefs.h:116:30: note: in expansion of macro 'Q_ENUM_IMPL' #define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) ^~~~~~~~~~~ C:\Qt\5.15.1\mingw81_64\include\QtWidgets/qmessagebox.h:79:5: note: in expansion of macro 'Q_ENUM' Q_ENUM(Icon) ^~~~~~ C:\Qt\5.15.1\mingw81_64\include/QtCore/qobjectdefs.h:114:48: note: previous definition of 'constexpr const QMetaObject* qt_getEnumMetaObject(QCborValue::Type)' was here friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ ^~~~~~~~~~~~~~~~~~~~ C:\Qt\5.15.1\mingw81_64\include/QtCore/qobjectdefs.h:116:30: note: in expansion of macro 'Q_ENUM_IMPL' #define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) ^~~~~~~~~~~ C:\Qt\5.15.1\mingw81_64\include/QtCore/qcborvalue.h:135:5: note: in expansion of macro 'Q_ENUM' Q_ENUM(Type) ^~~~~~
C:\Qt\5.15.1\mingw81_64\include\QtCore\qobjectdefs.h:115: warning: optimization attribute on 'constexpr const char* qt_getEnumName(QMessageBox::Icon)' follows definition but the attribute doesn't match [-Wattributes] C:\Qt\5.15.1\mingw81_64\include/QtCore/qobjectdefs.h:115:62: warning: optimization attribute on 'constexpr const char* qt_getEnumName(QMessageBox::Icon)' follows definition but the attribute doesn't match [-Wattributes] friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } ^~~~~~~~ C:\Qt\5.15.1\mingw81_64\include/QtCore/qobjectdefs.h:116:30: note: in expansion of macro 'Q_ENUM_IMPL' #define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) ^~~~~~~~~~~ C:\Qt\5.15.1\mingw81_64\include\QtWidgets/qmessagebox.h:79:5: note: in expansion of macro 'Q_ENUM' Q_ENUM(Icon) ^~~~~~ C:\Qt\5.15.1\mingw81_64\include/QtCore/qobjectdefs.h:115:41: note: previous definition of 'constexpr const char* qt_getEnumName(QAbstractItemView::DragDropMode)' was here friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } ^~~~~~~~~~~~~~ C:\Qt\5.15.1\mingw81_64\include/QtCore/qobjectdefs.h:116:30: note: in expansion of macro 'Q_ENUM_IMPL' #define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) ^~~~~~~~~~~ C:\Qt\5.15.1\mingw81_64\include/QtWidgets/qabstractitemview.h:185:5: note: in expansion of macro 'Q_ENUM' Q_ENUM(DragDropMode) ^~~~~~
C:\Qt\5.15.1\mingw81_64\include\QtGui\qvector2d.h:106: warning: optimization attribute on 'constexpr const QVector2D operator*(const QVector2D&, const QVector2D&)' follows definition but the attribute doesn't match [-Wattributes] In file included from C:\Qt\5.15.1\mingw81_64\include/QtGui/qevent.h:56, from C:\Qt\5.15.1\mingw81_64\include/QtGui/qtextlayout.h:49, from C:\Qt\5.15.1\mingw81_64\include/QtGui/qabstracttextdocumentlayout.h:45, from C:\Qt\5.15.1\mingw81_64\include/QtWidgets/qplaintextedit.h:51, from C:\Qt\5.15.1\mingw81_64\include/QtWidgets/QPlainTextEdit:1, from ./ui_app.h:20, from ..\..\rotortest\App\app.cpp:2: C:\Qt\5.15.1\mingw81_64\include/QtGui/qvector2d.h:106:102: warning: optimization attribute on 'constexpr const QVector2D operator*(const QVector2D&, const QVector2D&)' follows definition but the attribute doesn't match [-Wattributes] Q_DECL_CONSTEXPR friend inline const QVector2D operator*(const QVector2D &v1, const QVector2D &v2); ^
C:\Qt\5.15.1\mingw81_64\include\QtGui\qbrush.h:50: In file included from C:\Qt\5.15.1\mingw81_64\include/QtGui/qbrush.h:50, In file included from C:\Qt\5.15.1\mingw81_64\include/QtGui/qbrush.h:50, from C:\Qt\5.15.1\mingw81_64\include/QtGui/qpalette.h:46, from C:\Qt\5.15.1\mingw81_64\include/QtWidgets/qwidget.h:48, from C:\Qt\5.15.1\mingw81_64\include\QtWidgets/qmainwindow.h:44, from C:\Qt\5.15.1\mingw81_64\include\QtWidgets/QMainWindow:1, from ..\..\rotortest\App\app.h:4, from ..\..\rotortest\App\app.cpp:1: C:\Qt\5.15.1\mingw81_64\include/QtGui/qtransform.h:417:19: note: previous definition of 'QTransform operator-(const QTransform&, qreal)' was here inline QTransform operator -(const QTransform &a, qreal n) ^~~~~~~~
And others....
Is there a way to remove this warnings on this setup above?
Thank you,
-
@fem_dev
could be this bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89325
MingW 8.4 should have it fixed -
Simply add '-Wno-attributes' to your compiler flags.