0

For example I have '-Werror=return-type' because I'll get weird bugs if I accidentally forget to return a value in my function. I don't know why it isn't an error in C++. I also have missing-variable-declarations to avoid bugs. However I don't want unused-variable/label as errors on debug builds because I'll have a few of them before I finish writing the code. (That error is on in release build). Recently I added macro-redefined which inspired this question because there's a lot more I should add.

Which warning as errors do you guys recommend in debug builds?

Pac
  • 167
  • 4
  • For gcc, `-Wall -Werror`. All warnings are errors. Even unused variables. – Sam Varshavchik Sep 24 '20 at 16:08
  • Previously asked question that gives a _very_ complete list of warning. https://stackoverflow.com/questions/399850/best-compiler-warning-level-for-c-c-compilers – Chris Sep 24 '20 at 16:08
  • 1
    `-Wall -Wextra -Werro -pedantic_errors` are my default – NathanOliver Sep 24 '20 at 16:10
  • FYI: https://stackoverflow.com/questions/1735038/why-not-all-control-paths-return-a-value-is-warning-and-not-an-error – chris Sep 24 '20 at 16:16
  • For clang I use `-Weverything` and then selectively turn off warnings about incompatibility with earlier language standards. I usually start with `-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Werror -pedantic -pedantic-errors` – Ted Lyngmo Sep 24 '20 at 16:17

0 Answers0