Disabling errors but keeping warnings

Segher Boessenkool segher@kernel.crashing.org
Wed Apr 26 19:57:00 GMT 2017

On Wed, Apr 26, 2017 at 06:51:34PM +0200, Mason wrote:
> $ gcc -Wall -Werror -Wno-misleading-indentation -c foo.c 
> foo.c: In function 'foo':
> foo.c:1:22: error: unused variable 'a' [-Werror=unused-variable]
>  void foo(void) { int a; }
>                       ^
> foo.c: At top level:
> cc1: error: unrecognized command line option "-Wno-misleading-indentation" [-Werror]
> cc1: all warnings being treated as errors
> Hmmm, is there a way to ignore "error: unrecognized command line option" ?

The manual says:

When an unrecognized warning option is requested (e.g.,
@option{-Wunknown-warning}), GCC emits a diagnostic stating
that the option is not recognized.  However, if the @option{-Wno-} form
is used, the behavior is slightly different: no diagnostic is
produced for @option{-Wno-unknown-warning} unless other diagnostics
are being produced.  This allows the use of new @option{-Wno-} options
with old compilers, but if something goes wrong, the compiler
warns that an unrecognized option is present.

In your example another diagnostic _is_ produced.


More information about the Gcc-help mailing list