4

I am working with c++ code base which emits many warnings due to which its hard to catch or notice new warnings being introduce by code I am adding or changing.

this is painful as I am not going to spend time resolving all the warning coming due to other modules, but I certainly do not want to add code which emits warning.

I wonder if there is some tool in gcc or external which can help here.

I can think of a painful way of taking a diff of compiler output with and without my code , but it will make my coffee taste much bitter.

Any suggestion on this?

user8063157
  • 285
  • 1
  • 13

1 Answers1

4

If the problem stems from third-party source files, you can build some files with warning flags on, and other files with warning flags off. GCC has a whole range of well-documented warning control options.

If the problem stems from third-party headers that you include in your code, you can use -isystem to have headers under that path treated as "system headers", whose warnings are typically ignored.

If the code is more entwined, you are out of luck.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • 1
    `-isystem` does not replace the `#include` in the code, it only tells the compiler to treat the header files form the specified include path as system header files and don't emit any warnings for the code found therein. – Rene Jul 11 '17 at 12:36
  • @Rene: Oh yes, thanks. Brain was thinking of `-include`, I suppose – Lightness Races in Orbit Jul 11 '17 at 12:58
  • If you want better control than just on/off per file it seems you can use pragmas: https://stackoverflow.com/questions/3378560/how-to-disable-gcc-warnings-for-a-few-lines-of-code – Hans Olsson Jul 11 '17 at 13:43
  • @HansOlsson: It seems you can't really https://stackoverflow.com/questions/3378560/how-to-disable-gcc-warnings-for-a-few-lines-of-code#comment50983002_3378635 – Lightness Races in Orbit Jul 11 '17 at 14:40