7.6.4.2 Options That Are Not Implied by
-Wall
The following -W
options are not implied by
-Wall
. Some of them warn about constructions that 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.
Option | Definition |
---|---|
-Wextra ,
-W | Print extra warning messages for
specific events. For details, see The -W Option
section. |
-Waggregate-retur n | Warn if any functions that return structures or unions are defined or called. |
-Wbad-function-cast | Warn whenever a function call is cast
to a non-matching type. For example, warn if int foof()
is cast to anything * . |
-Wcast-align | Warn whenever a pointer is cast, such
that the required alignment of the target is increased. For example,
warn if a char * is cast to an int *
. |
-Wcast-qual | Warn whenever a pointer is cast, so as
to remove a type qualifier from the target type. For example, warn if a
const char * is cast to an ordinary char
* . |
-Wconversion | Warn if a prototype causes a type
conversion that is different from what would happen to the same argument
in the absence of a prototype. This includes conversions of fixed point
to floating and vice versa, and conversions changing the width or
signedness of a fixed point argument, except when the same as the
default promotion. Also, warn if a negative integer
constant expression is implicitly converted to an unsigned type. For
example, warn about the assignment |
-Werror | Make all warnings into errors. |
-Winline | Warn if a function can not be inlined
and was either declared as inline, or else the
-finline-functions option was given. |
-Wlarger-than=len | Warn whenever an object of larger than
len bytes is defined. |
-Wlong-long
| Warn if long long type
is used. This is default. To inhibit the warning messages, use
-Wno-long-long . Flags -Wlong-long
and -Wno-long-long are taken into account only when
-pedantic flag is used. |
-Wmissing-declarations | Warn if a global function is defined without a previous declaration. Do so even if the definition itself provides a prototype. |
-Wmissing-
format-attribute | If -Wformat is
enabled, also warn about functions that might be candidates for format
attributes. Note these are only possible candidates, not absolute ones.
This option has no effect unless -Wformat is
enabled. |
-Wmissing-noreturn | Warn about functions that might be
candidates for attribute noreturn . These are only
possible candidates, not absolute ones. Care should be taken to manually
verify functions. Actually, do not ever return before adding the
noreturn attribute; otherwise subtle code
generation bugs could be introduced. |
-Wmissing-prototypes | Warn if a global function is defined without a previous prototype declaration. This warning is issued even if the definition itself provides a prototype. (This option can be used to detect global functions that are not declared in header files.) |
-Wnested-externs | Warn if an extern
declaration is encountered within a function. |
-Wno-deprecated-declarations | Do not warn about uses of functions,
variables and types marked as deprecated by using the
deprecated attribute. |
-Wpadded | Warn if padding is included in a structure, either to align an element of the structure or to align the whole structure. |
-Wpointer-arith | Warn about anything that depends on the
size of a function type or of void . The compiler
assigns these types a size of 1, for convenience in calculations with
void * pointers and pointers to functions. |
-Wredundant-decls | Warn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing. |
-Wshadow | Warn whenever a local variable shadows another local variable. |
-Wsign-compare
| Warn when a comparison between signed
and unsigned values could produce an incorrect result when the signed
value is converted to unsigned. This warning is also enabled by
-W ; to get the other warnings of
-W without this warning, use -W
-Wno-sign-compare . |
-Wstrict-prototypes | Warn if a function is declared or defined without specifying the argument types. (An old-style function definition is permitted without a warning if preceded by a declaration which specifies the argument types.) |
-Wtraditional | Warn about certain constructs that
behave differently in traditional and ANSI C.
|
-Wundef | Warn if an undefined identifier is
evaluated in an #if directive. |
-Wwrite-strings | Give string constants the type
const char[length] so that copying the address of
one into a non-const char * pointer will get a warning.
These warnings will help you find at compile time code that you can try
to write into a string constant, but only if you have been very careful
about using const in declarations and prototypes.
Otherwise, it will just be a nuisance, which is why
-Wall does not request these warnings. |