Search code examples
c++gccconditional-statementscompiler-warningsqmake

Conditionally disable warnings with qmake/gcc?


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?


Solution

  • Jonathan, I think the problem is where your source files are including header files from 3rd party libraries, and you want to switch off the warnings for the latter.

    Kevin, i think you can use pragmas to control warnings : gcc diagnostic pragmas

    You could add these before and after any #includes for 3rd party libs.