Chapter 4. GCC Command Options
-Wall
All of the above
some users consider questionable, and that are easy to avoid (or modify to prevent the warning),
even in conjunction with macros. This also enables some language-specific warnings described in
Section 4.5 Options Controlling C++ Dialect and Section 4.6 Options Controlling Objective-C
Dialect.
The following
-W...
users generally do not consider questionable, but which occasionally you might wish to check for;
others warn about constructions that are necessary or hard to avoid in some cases, and there is no
simple way to modify the code to suppress the warning.
-Wextra
(This option used to be called
descriptive.) Print extra warning messages for these events:
A function can return either with or without a value. (Falling off the end of the function body is
•
considered returning without a value.) For example, this function would evoke such a warning:
foo (a)
{
if (a
return a;
}
An expression-statement or the left-hand side of a comma expression contains no side effects.
•
To suppress the warning, cast the unused expression to void. For example, an expression such
as
will cause a warning, but
x[i,j]
An unsigned value is compared against zero with
•
A comparison like
•
is a different interpretation from that of ordinary mathematical notation.
Storage-class specifiers like
•
C Standard, this usage is obsolescent.
The return type of a function has a type qualifier such as
•
fect, since the value returned by a function is not an lvalue. (But don't warn about the GNU ex-
tension of
volatile void
is specified.)
If
or
•
-Wall
-Wunused
A comparison between signed and unsigned values could produce an incorrect result when
•
the signed value is converted to unsigned. (But don't warn if
specified.)
An aggregate has an initializer which does not initialize all members. For example, the follow-
•
ing code would cause such a warning, because
struct s { int f, g, h; };
struct s x = { 3, 4 };
A function parameter is declared without a type specifier in K&R-style functions:
•
void foo(bar) { }
An empty body occurs in an
•
A pointer is compared against integer zero with
•
A variable might be changed by
•
options combined. This enables all the warnings about constructions that
-W
options are not implied by
. The older name is still supported, but the newer name is more
-W
0)
appears; this is equivalent to
x =y =z
static
return types. That extension will be warned about if
is also specified, warn about unused arguments.
or
if
longjmp
. Some of them warn about constructions that
-Wall
will not.
x[(void)i,j]
or
are not the first things in a declaration. According to the
const
would be implicitly initialized to zero:
x.h
statement.
else
,
, , or
=
or
.
vfork
.
=
(x =y ? 1 : 0)
. Such a type qualifier has no ef-
-Wno-sign-compare
.
=
39
, which
= z
-pedantic
is also
Need help?
Do you have a question about the ENTERPRISE LINUX 4 and is the answer not in the manual?