Make a warning "makes a pointer from the integer without casting" as an error

I am trying to make a warning warning: passing argument 1 of "func makes a pointer to an integer without casting" as an error, but cannot find the option name.

I tried all warnings from

gcc -Q --help=warnings | grep enabled 

I tried either to do -Werror = XXXX, and the option name from the list,

or even tried to disable the warning -Wno-XXXX and could not disconnect.

Does anyone know an option for this particular warning?

+4
source share
2 answers

I also wanted to know about this, so I checked the source of gcc (4.8.1). In c-typeck.c there is the following code that emits a warning:

  WARN_FOR_ASSIGNMENT (location, 0, G_("passing argument %d of %qE makes " "pointer from integer without a cast"), G_("assignment makes pointer from integer " "without a cast"), G_("initialization makes pointer from " "integer without a cast"), G_("return makes pointer from integer " "without a cast")); 

See second argument 0 for WAIT_FOR_ASSIGNMENT ? This is usually a flag for one of the diagnostic parameters. In this case, however, it is zero, so I am afraid that this means that the error cannot be specifically caused by the error.

+2
source

As indicated in the gcc manual

-Werror = Provide the specified warning in an error message. A qualifier for warnings is added, for example -Werror = switch enables warnings controlled by -Wswitch in error. This switch takes a negative form, for use to negate -Werror for specific warnings, for example -Wno-error = switch makes -Wswitch warnings are not errors, even when -Werror is valid. You can use the -fdiagnostics-show-option option so that each monitored alert is changed using the option that monitors it to determine what to use with this option.

any supported option should be specified using the -fdiagnostics-show-option switch.

If you're lucky, your version of gcc may enable you to selectively turn your warning into an error message. The version that I use definitely does not, therefore either using

-Werror Prevent all warnings.

or

-pedantic-error Like -pedantic, except that errors are generated, not warnings.

may be the only options for gcc to throw an error.

0
source

Source: https://habr.com/ru/post/1437254/


All Articles