Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QTCreator add -Weffc++ to build
I want to add
-Weffc++as a flag for
gccso i can find some more bad practices on compilation.
When I do this in the .pro file of my project:
QMAKE_CXXFLAGS += -Weffc++
It also throws me a million errors with the qt files. how can I tell the compiler to only look into my files?
I don't think that is possible since for the compiler there are
no theirs or mine files. its all just files in the project.
So you have to process the output to exclude warnings for files you are not interested in.
process the output
what do you mean with process the output?
find a way to filter it using other app or similar to extract the
lines you want to see.
Its not possible directly in creator.
Can you show one of the unwanted warnings ?
well it starts like this:
In file included from /home/sandro/Qt/5.13.0/gcc_64/include/QtCore/qglobal.h:105:0, from /home/sandro/Qt/5.13.0/gcc_64/include/QtGui/qtguiglobal.h:43, from /home/sandro/Qt/5.13.0/gcc_64/include/QtGui/qimage.h:43, from /home/sandro/Qt/5.13.0/gcc_64/include/QtGui/QImage:1, from ../../minefield/src/converttograyscale.h:24, from ../../minefield/src/converttograyscale.cpp:20: /home/sandro/Qt/5.13.0/gcc_64/include/QtCore/qcompilerdetection.h:1129:26: warning: prefix ‘T QBasicAtomicInteger<T>::operator++()’ should return ‘QBasicAtomicInteger<T>&’ [-Weffc++] # define Q_DECL_NOEXCEPT noexcept ^ /home/sandro/Qt/5.13.0/gcc_64/include/QtCore/qcompilerdetection.h:1139:25: note: in expansion of macro ‘Q_DECL_NOEXCEPT’ # define Q_DECL_NOTHROW Q_DECL_NOEXCEPT ^~~~~~~~~~~~~~~ /home/sandro/Qt/5.13.0/gcc_64/include/QtCore/qbasicatomic.h:198:20: note: in expansion of macro ‘Q_DECL_NOTHROW’ T operator++() Q_DECL_NOTHROW ^~~~~~~~~~~~~~ /home/sandro/Qt/5.13.0/gcc_64/include/QtCore/qcompilerdetection.h:1129:26: warning: postfix ‘T QBasicAtomicInteger<T>::operator++(int)’ should return ‘QBasicAtomicInteger<T>’ [-Weffc++] # define Q_DECL_NOEXCEPT noexcept ^ /home/sandro/Qt/5.13.0/gcc_64/include/QtCore/qcompilerdetection.h:1139:25: note: in expansion of macro ‘Q_DECL_NOEXCEPT’ # define Q_DECL_NOTHROW Q_DECL_NOEXCEPT ^~~~~~~~~~~~~~~ /home/sandro/Qt/5.13.0/gcc_64/include/QtCore/qbasicatomic.h:200:23: note: in expansion of macro ‘Q_DECL_NOTHROW’ T operator++(int) Q_DECL_NOTHROW
maybe you could scan for
and remove that line and next line if it follows the same pattern ?
can i do that in creator automatically?
nope. write small qt program to do it.
Should be pretty simple if thats the patthern the warnings has.