Compiler warnings generally provide useful hints for common programming errors. It is often recommended to turn compiler warnings into errors (e.g. here). In my experience, this is useful to prevent warnings from getting ignored, especially on larger code bases or in automated build systems. However, some warnings are useful as warnings and cannot be turned into errors, either because they can happen to be false positives or because the code base cannot be adapted at once but it takes some transition period.
As a workaround, I could compile the same code twice:
- One run with most or all warnings enabled (e.g.
-Wextra), but without turning them into errors (i.e., without-Werror) - A second run with a smaller set of warnings, but with pedantic settings (i.e., with the
-Werrorcommand line option)
This way the code project would benefit from more warnings than it could currently fix.
Is there a way to do this directly, i.e., with a single compilation step, not two?
I have read some mentions of the -Wno-error=[name] option in another question and it barely mentioned in the latest clang command line reference, but I lack details. In case those provide a solution for my question, can you please elaborate what it does and/or provide a link to where it is documented?
-Werrormeans turn all warnings into errors. Not to be confused with-pedantic-errorswhich means "give errors for standard C violations". Pedantic is a poorly chosen name, it's only pedantic by the standard set by some loony aimlessly hacking away in GNU C with wild & crazy non-standard extensions just for the heck of non-conformance and non-portability.-Wno-error=[warning-name]which is not mentioned in the question you linked.conversion, it is fully covered by this one.