Re: Disabling errors but keeping warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 26/04/2017 20:44, Segher Boessenkool wrote:

> 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.

The documentation I was looking at was

  https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

which AFAIU currently applies to GCC 6.


Thanks for pointing out the -Wfatal-errors text.

> You can request many specific warnings with options beginning with
> '-W', for example -Wimplicit to request warnings on implicit
> declarations. Each of these specific warning options also has a
> negative form beginning '-Wno-' to turn off warnings; for example,
> -Wno-implicit. This manual lists only one of the two forms, whichever
> is not the default. For further language-specific options also refer
> to C++ Dialect Options and Objective-C and Objective-C++ Dialect
> Options.
> 
> Some options, such as -Wall and -Wextra, turn on other options, such
> as -Wunused, which may turn on further options, such as
> -Wunused-value. The combined effect of positive and negative forms is
> that more specific options have priority over less specific ones,
> independently of their position in the command-line. For options of
> the same specificity, the last one takes effect. Options enabled or
> disabled via pragmas (see Diagnostic Pragmas) take effect as if they
> appeared at the end of the command-line.
> 
> When an unrecognized warning option is requested (e.g.,
> -Wunknown-warning), GCC emits a diagnostic stating that the option is
> not recognized. However, if the -Wno- form is used, the behavior is
> slightly different: no diagnostic is produced for
> -Wno-unknown-warning unless other diagnostics are being produced.
> This allows the use of new -Wno- options with old compilers, but if
> something goes wrong, the compiler warns that an unrecognized option
> is present.


My example was using gcc 4.8; perhaps the GCC devs have
improved the handling of -Wno-error over several versions.

I'll run tests with several different versions of GCC.

Regards.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux