Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Suppress warnings from Qt headers with clang more cleanly
Qt 6.11 is out! See what's new in the release blog

Suppress warnings from Qt headers with clang more cleanly

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sethcall
    wrote on last edited by
    #1

    Hi all,

    On a mac using clang, I'm am making solid progress suppressing Qt warnings that occur as I'm building my code.

    The answer, I think, is to add the -isystem <dir> argument as a CXX_FLAGS (unfortunately -isystem-prefix appears unsupported by macx clang).

    Here is something I tried:

    @LIBS_USED_FOR_QT = QtCore QtSql QtMultimediaWidgets QtSensors QtSvg QtXml QtPrintSupport QtWidgets QtQuick QtQml QtPositioning QtGui QtWebKitWidgets

    for(somelib, $$list($$LIBS_USED_FOR_QT)) {
    QMAKE_CXXFLAGS += -isystem $$(QTDIR)/lib/$${somelib}.framework/Versions/5/Headers
    QMAKE_CXXFLAGS += -isystem $$(QTDIR)/lib/$${somelib}.framework/Headers
    }@

    I did both /Versions/5/Headers and /Headers because I see both show up in warning systems.

    You also have to be careful to not do this:

    #include <QtCore/QStringList>

    and instead do

    #include <QStringList>

    ... I have no idea why on that point.

    But I still have 2 problems with my approach:

    I'm listing out all the libraries I'm using, but I believe there is a Qt variable that has this information. The docs lead me to believe QMAKE_LIBS_QT should have them, but it's always empty as far as I can tell (I replace QMAKE_LIBS_QT with LIBS_USED_FOR_QT, and nothing at all added to the clang command line).

    The moc compilation still emits warnings, because mocs use the #include <QtCore/QObject> syntax, which as I mentioned is a problem, but I have no idea why.

    Any thoughts on how I can do this better? Is someone else doing this already and figured out a better way?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sethcall
      wrote on last edited by
      #2

      I have a problem with Boost warnings I'm working through now. Boost has a ton of folders from where headers may be located, so I really need a way to recursively grab all folders in the root boost include folder, and add them all to -isystem. I see no way of doing that though...

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved