Search code examples
clangcompiler-flags

Clang: Promoting all Warnings to Errors Except for …


In the project I currently am — and probably will for some time be — working on, we have decided to use the -Werror flag, as our previous “No warnings!” policy did not work out as intended.

This, however, imposes a certain problem:

API can no longer be marked as deprecated in a way that a) is flagged by the normal build toolchain, and b) doesn’t break the build.

So I guess the question boils down to:

Is there a flag like -Werror-no-${something_I_dont_want_to_promote_to_an_error}?

I found #pragma clang diagnostic error to almost achieve what I want — except that I fail to catch all the warnings that are enabled implicitly by the compiler…

Thanks in advance.


Solution

  • From the manual:

    -Wno-error=foo: Turn warning "foo" into a warning even if -Werror is specified.