1

I think we all know how compiler warnings can help prevent bugs and that it's good to have them enabled.

So the question is: how to enable all compiler warnings?

The major C++ compilers for me are:

  • g++
  • clang++
  • Visual Studio's compiler

I am aware of the common settings for these compilers:

  • -Wall -Wextra -pedantic (common for g++ and clang++)
  • /W4 (vc++)

However, there are some more warnings that can be enabled more individually (like for example -Wconversion).

Is is possible to enable all warnings without passing a huge number of individual switches? If all is impractical (due to for example lots of warnings generated by standard library headers, or many false positives), how to enable the most useful subset?

I understand "the most useful subset" differs depending on the project, but perhaps there is a good subset each project can start with.

Krzysiek Karbowiak
  • 1,655
  • 1
  • 9
  • 17
  • You don't want all warnings. The reason it's not automatically all on is because there's false positives, and how much you tolerate them is a decision. – Passer By Feb 01 '22 at 11:08
  • 1
    `clang++` `-Weverything` and then `-` the ones you do not want, like all `c++98-*` compatibility warnings. – Ted Lyngmo Feb 01 '22 at 11:09
  • @PasserBy: and how can I make my decision if I don't enable all and see how bad the situation is? And yes, I'm fully aware of the false positives and the possible noise. – Krzysiek Karbowiak Feb 01 '22 at 11:13
  • 1
    https://stackoverflow.com/questions/11714827/how-to-turn-on-literally-all-of-gccs-warnings; https://stackoverflow.com/questions/24075528/how-do-i-enable-all-warnings-in-visual-studio-2008-in-a-project/24284555 – user17732522 Feb 01 '22 at 11:14
  • I would suggest that any answer to *this* question would actually be better suited as a supplemental answer to the *linked* question. But I'd like to see others' opinions before/if I close this as a duplicate. – Adrian Mole Feb 01 '22 at 11:16
  • ... plus there are the Q/As that @user17732522 just linked. – Adrian Mole Feb 01 '22 at 11:17

0 Answers0