Disabling errors but keeping warnings

Mason slash.tmp@free.fr
Wed Apr 26 18:54:00 GMT 2017


Hello,

The build system I use sets -Wall -Werror

New versions of GCC introduce new warnings, or in my case new errors :-)

For example, error: this 'if' clause does not guard... [-Werror=misleading-indentation]

Ideally, I'd want to "downgrade" some errors into a simple warnings.

Example with -Wunused-variable

$ gcc -Wall -Werror -Wno-error=unused-variable -c foo.c 
foo.c: In function 'foo':
foo.c:1:22: warning: unused variable 'a' [-Wunused-variable]
 void foo(void) { int a; }
                      ^

Perfect! The above is exactly what I want.

However, if I do that with a switch that is supported only
in later versions of gcc:

$ gcc -Wall -Werror -Wno-error=misleading-indentation -c foo.c 
cc1: error: -Werror=misleading-indentation: no option -Wmisleading-indentation

Doesn't work :-(


$ 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" ?

Regards.



More information about the Gcc-help mailing list