qglobal.h:391:11: error: 'maybe_unused' attribute cannot be applied to types
-
I have a project I haven't touched in some time. It was written with Qt 5, so I am trying to compile it against Qt 5.15 and I am getting an the following error in Qt's code:
/Users/addy/Qt-Versions/Qt5.15/5.15.2/clang_64/lib/QtCore.framework/Headers/qglobal.h:391:11: error: 'maybe_unused' attribute cannot be applied to types constexpr Q_DECL_UNUSED Deprecated_t Deprecated = {}; ^ /usr/local/include/QtCore/qcompilerdetection.h:940:27: note: expanded from macro 'Q_DECL_UNUSED' # define Q_DECL_UNUSED [[maybe_unused]] ^ In file included from /Users/addy/src/Owl/build/src/Data/moc_Board.cpp:10: In file included from /Users/addy/src/Owl/build/src/Data/../../../src/Data/Board.h:7: In file included from /Users/addy/Qt-Versions/Qt5.15/5.15.2/clang_64/lib/QtCore.framework/Headers/QtCore:4: /Users/addy/Qt-Versions/Qt5.15/5.15.2/clang_64/lib/QtCore.framework/Headers/qglobal.h:892:50: error: an attribute list cannot appear here Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(double p1, double p2) ^~~~~~~~~~~~~ /usr/local/include/QtCore/qcompilerdetection.h:940:25: note: expanded from macro 'Q_DECL_UNUSED' # define Q_DECL_UNUSED [[maybe_unused]] ^~~~~~~~~~~~~~~~ In file included from /Users/addy/src/Owl/build/src/Data/moc_Board.cpp:10: In file included from /Users/addy/src/Owl/build/src/Data/../../../src/Data/Board.h:7: In file included from /Users/addy/Qt-Versions/Qt5.15/5.15.2/clang_64/lib/QtCore.framework/Headers/QtCore:4: /Users/addy/Qt-Versions/Qt5.15/5.15.2/clang_64/lib/QtCore.framework/Headers/qglobal.h:897:50: error: an attribute list cannot appear here Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(float p1, float p2) ^~~~~~~~~~~~~ /usr/local/include/QtCore/qcompilerdetection.h:940:25: note: expanded from macro 'Q_DECL_UNUSED' # define Q_DECL_UNUSED [[maybe_unused]] ^~~~~~~~~~~~~~~~ In file included from /Users/addy/src/Owl/build/src/Data/moc_Board.cpp:10: In file included from /Users/addy/src/Owl/build/src/Data/../../../src/Data/Board.h:7: In file included from /Users/addy/Qt-Versions/Qt5.15/5.15.2/clang_64/lib/QtCore.framework/Headers/QtCore:4: /Users/addy/Qt-Versions/Qt5.15/5.15.2/clang_64/lib/QtCore.framework/Headers/qglobal.h:902:50: error: an attribute list cannot appear here Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNull(double d) ^~~~~~~~~~~~~ /usr/local/include/QtCore/qcompilerdetection.h:940:25: note: expanded from macro 'Q_DECL_UNUSED'
It goes on for a while with a bunch of other errors in Qt's source files. I'm using CMake with C++20, but I'm not sure where to go from here in order to resolve it.
Any suggestions would be most appreciated!
-
What gcc/clang version do you use?
-
I encountered the same error on the same line, and judging by the pasted output above I think I'm on a similar platform.
The error occurs with the default Clang compiler shipped with Xcode 15.0.1, on macOS Sonoma 14.1.2. My architecture is arm64.
Apple clang version 15.0.0 (clang-1500.0.40.1) Target: arm64-apple-darwin23.1.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Unlike @Wolosocu I have Qt 5.15 installed via Homebrew.
I am trying to compile Gazebo, a robotics simulation package. The entire failing command line invocation follows. Note that it is compiling for C++17 (passing
-std=c++17
).There are a ton of other errors that are produced, but I suspect they all have the same root cause.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DMAC_OS_X_VERSION=1080 -DPROTOBUF_USE_DLLS -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_QUICKCONTROLS2_LIB -DQT_QUICK_LIB -DQT_WIDGETS_LIB -DSHARED_LIBRARY_PREFIX=\"lib\" -DSHARED_LIBRARY_SUFFIX=\".dylib\" -Dgz_gui8_EXPORTS -I/Users/rzg/Projects/2023/12/gz-maritime-tutorials/build/gz-gui8/include/gz/gui/gz-gui8_autogen/include -I/Users/rzg/Projects/2023/12/gz-maritime-tutorials/src/gz-gui/include -I/Users/rzg/Projects/2023/12/gz-maritime-tutorials/build/gz-gui8/include -I/Users/rzg/Projects/2023/12/gz-maritime-tutorials/build/gz-gui8/core/include -iframework /opt/homebrew/opt/qt@5/lib -isystem /opt/homebrew/opt/qt@5/lib/QtCore.framework/Headers -isystem /opt/homebrew/opt/qt@5/./mkspecs/macx-clang -isystem /opt/homebrew/opt/qt@5/lib/QtQml.framework/Headers -isystem /opt/homebrew/opt/qt@5/lib/QtNetwork.framework/Headers -isystem /opt/homebrew/opt/qt@5/lib/QtQuick.framework/Headers -isystem /opt/homebrew/opt/qt@5/lib/QtGui.framework/Headers -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks/OpenGL.framework/Headers -isystem /opt/homebrew/opt/qt@5/lib/QtQmlModels.framework/Headers -isystem /opt/homebrew/opt/qt@5/lib/QtQuickControls2.framework/Headers -isystem /opt/homebrew/opt/qt@5/lib/QtWidgets.framework/Headers -isystem /Users/rzg/Projects/2023/12/gz-maritime-tutorials/install/include/gz/common5 -isystem /Users/rzg/Projects/2023/12/gz-maritime-tutorials/install/include/gz/utils2 -isystem /Users/rzg/Projects/2023/12/gz-maritime-tutorials/install/include/gz/math7 -isystem /Users/rzg/Projects/2023/12/gz-maritime-tutorials/install/include/gz/msgs10 -isystem /opt/homebrew/include -isystem /opt/homebrew/Cellar/tinyxml2/9.0.0/include -isystem /Users/rzg/Projects/2023/12/gz-maritime-tutorials/install/include/gz/plugin2 -isystem /Users/rzg/Projects/2023/12/gz-maritime-tutorials/install/include/gz/transport13 -stdlib=libc++ -O2 -g -DNDEBUG -std=c++17 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -fPIC -I/opt/homebrew/Cellar/tinyxml2/9.0.0/include -fPIC -MD -MT include/gz/gui/CMakeFiles/gz-gui8.dir/__/__/__/src/Application.cc.o -MF CMakeFiles/gz-gui8.dir/__/__/__/src/Application.cc.o.d -o CMakeFiles/gz-gui8.dir/__/__/__/src/Application.cc.o -c /Users/rzg/Projects/2023/12/gz-maritime-tutorials/src/gz-gui/src/Application.cc
-