Why "'X' used but never defined" is a warning and not error in gcc?

Oleg Endo oleg.endo@t-online.de
Mon Oct 8 16:14:00 GMT 2012


On Mon, 2012-10-08 at 17:30 +0200, Vincent Lefevre wrote:
> On 2012-10-08 12:43:09 +0200, Oleg Endo wrote:
> > Doesn't look so.  You can turn all warnings into errors by -Werror, but
> > there's no option to control this particular warning individually.
> 
> It is possible to turn *particular* warnings into errors, not just
> all warnings, with -Werror=<list_of_warnings>.

Yes, that is true.  But there is no way to turn off or turn into an
error the warning that is output in _this_particular_case_, because
there's no flag in GCC's code to do so.

gcc/toplev.c, function check_global_declaration_1, around line 470:

&& (warn_unused_function
    || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
  {
    if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
      pedwarn (input_location, 0, "%q+F used but never defined", decl);

This particular warning can be turned into an error by specifying
-pedantic-errors

Cheers,
Oleg



More information about the Gcc-help mailing list