W

Do not issue warning messages. Same as --no-warnings. -W

This option enables the issuing of a family of warning messages dealing primarily with code that could possibly cause a problem, but it could also be what was intended by the programmer. This option enables all of the following:

■ Comparison A warning is issued if an unsigned value is tested for being less than zero. For example, because unsigned values can never be negative, the following test will always be false:

■ Comparison A warning is issued for the comparison of a signed value with an unsigned value. An incorrect result can be produced when the unsigned value is converted to a signed value for the comparison. This warning can be suppressed by -Wno-sign-compare.

■ Comparison Algebraic notation and the C sytnax for comparison are not the same. A warning will be issued for the following statement:

In algebraic notation this expression is true only if b lies in the open interval between a and c. In C, this expression is the same as the following, which is very different:

int result; result = a < b; if(result < b) . . .

■ Const return Issue a warning for the return value of a function being declared as const. The const declaration has no meaning here because the return value from a function is an rvalue.

■ Aggregate initializers A warning is issued if initial values are specified for an aggregate data type, but values are not supplied for all members of the aggregate. In the following example an error message would be issued for both the array and the struct:

struct { int a; int b; int c; } trmp = { 1, 2 }; int arr[10] = { 1, 2, 3, 4, 5 };

■ No side effect A warning is issued for a statement that has no effect. For example, the result of the following addition is not used:

■ Overflow In Fortran, warnings are issued when floating point constant declarations overflow.

■ Return value Issue a warning if a function is written so that it may or may not return a value, as in the following example which does not return value if x is negative:

ambigret(int x) {

return(x);

■ Static syntax Issue a warning if the keyword static does not come first on a declaration line. This ordering is no longer a requirement in standard C.

■ Unused arguments If either -Wall or -Wunused is specified along with -W, a warning is issued for any unused arguments in the body of a function.

This option can be written --extra-warnings.

-Wa,optionlist |Asn

The optionlist is a list of one or more comma separated lists of options to be passed to the assembler. The options are split at the commas and each one is provided to the assembler as a command line option.

Also see -Wp and -Wl. This option can be written as --for-assembler.

Was this article helpful?

0 0

Post a comment