Conditionally disable warnings on ceratin source files in qmake?
Hello,
I am involved with a software project written in Qt and built with qmake and gcc on Linux. We have to link to a third-party library that is of fairly low quality and spews tons of warnings. I would like to use -W -Wall on our source code, but pass -w to the nasty third-party library to keep the console free of noise and clutter so we can focus on our code quality.
In qmake, is there a way to conditionally add CFLAGS/CXXFLAGS to certain files and libraries?
Re: Conditionally disable warnings on ceratin source files in qmake?
There's QMAKE_CXXFLAGS and "CONFIG += no_warn" (or was it "CONFIG -= warn_on"?).
Re: Conditionally disable warnings on ceratin source files in qmake?
I only would like to disable warnings for the bad third-party header files, but very much would like to keep warnings on my code!
Re: Conditionally disable warnings on ceratin source files in qmake?
So it's not a separate library but its sources are included to the main project?
Re: Conditionally disable warnings on ceratin source files in qmake?
yes, .h files included from our code
Re: Conditionally disable warnings on ceratin source files in qmake?
We have to use their headers to interface with their API.
Re: Conditionally disable warnings on ceratin source files in qmake?
The compiler flags can only be set for c/cpp files.
If you code a perfect cpp file that includes an ugly third party header it is bad luck for you.
You should force the third party developers to stick to some guidelines and demand a measurable quality from them.
Maybe gcc provides an option to selectively switch off a certain warning.
I know this from the Green Hills compiler that we use for automotive controllers. Every possible warning has a number that can be used as argument for that option.
Re: Conditionally disable warnings on ceratin source files in qmake?
I think you can do it by these:
Code:
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#include "third_party.h"
#pragma GCC diagnostic warning "-Wunused-parameter"
#pragma GCC diagnostic warning "-Wunused-variable"
#include "your_header.h"
Reference:
http://gcc.gnu.org/onlinedocs/gcc-4....nostic-Pragmas
http://gcc.gnu.org/onlinedocs/gcc-3....ning%20Options