Errors in QT headers using clang

Questions:


My question is this: how do I create my QT project without disabling alerts at all (or do you need to sort a million aimless to find your own)? Can I suppress warnings only for QT headers?

Details:


Question


A few months ago, I started the QT project at QT-Creator. I used gcc 4.6 at the time. After some other priorities were established, and I found myself without time to work on the project so far. In the meantime, I switched to using clang. When I set up my QT project to use clang - which project was compiled without warning in g ++, it generated about 263 warnings in the QT headers themselves. Mostly character conversion and unreachable code.


Attempts


To try to get around this, I added the -system / path / to / QT / include / dir based on this entry in the Clang User Guide , but it doesn’t seem to affect anything. Although I'm not sure, I think this is because my code #include QT headers by name and not by directory. Although the solution for this might be to manually list each individual QT header (not tried), this would mean that I would have to update it every time I updated QT or used a new header. Of course, there is a better solution.

As requested here, an executable compilation command is executed:

 clang++ -c -pipe -Qunused-arguments -Weverything -cxx-isystem /path/to/qt/4.8.3/include/ -g -D_REENTRANT -DQT_NO_KEYWORDS -DQT_SHARED -I/path/to/qt/x86_64/4.8.3/mkspecs/unsupported/linux-clang -I. -I.moc -I.ui -I/path/to/qt/4.8.3/include/ -o .obj/main.o main.cpp 

the functions


I use:

  • Linux 3.2.0-40-generi # 64-Ubuntu SMP x86_64 GNU / Linux
    • While others on my team use Windows
  • QT 2.6.2 creator
  • QT 4.8.3
  • clang version 3.2 (trunk 165250) (llvm / trunk 165249)
    • Target: x86_64-unknown-linux-gnu
+8
c ++ clang qt4
source share
2 answers

I will answer my question, because, as it turns out, this is a special environmental attack in this case.

I have two copies of the QT libraries on my dev machine, one system-wide and one project-specific (included in VCS). There is no qmake in the project libraries, so I used my qmake system, which added a different path than I included in my specification systems. To solve this problem, I added

 QMAKE_INCDIR_QT = 

in qmake.conf (in qt / mkspecs / unsupported / linux-clang /)

Since someone else in the project has been fanatical of qmake in using project libraries everywhere.

+2
source share

For those who stumbled upon this question with a more general problem than the author. Try pasting:

 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/ } 

in your .pro file. Addtionally avoid includes, for example, #include <QtCore/QtCore> instead of << 22>

This tamed qt is pretty effective for me.

see also this source

+1
source share

All Articles