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.

Table 7-9. Warning/Error Options not Implied by -Wall
OptionDefinition
-Wextra, -WPrint extra warning messages for specific events. For details, see The -W Option section.
-Waggregate-returnWarn if any functions that return structures or unions are defined or called.
-Wbad-function-castWarn whenever a function call is cast to a non-matching type. For example, warn if int foof() is cast to anything *.
-Wcast-alignWarn 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-qualWarn 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 *.
-WconversionWarn 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 x = -1 if x is unsigned. But do not warn about explicit casts like (unsigned) -1.

-WerrorMake all warnings into errors.
-WinlineWarn if a function can not be inlined and was either declared as inline, or else the -finline-functions option was given.
-Wlarger-than=lenWarn whenever an object of larger than len bytes is defined.
-Wlong-long

-Wno-long-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-declarationsWarn if a global function is defined without a previous declaration. Do so even if the definition itself provides a prototype.
-Wmissing-
format-attributeIf -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-noreturnWarn 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-prototypesWarn 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-externsWarn if an extern declaration is encountered within a function.
-Wno-deprecated-declarationsDo not warn about uses of functions, variables and types marked as deprecated by using the deprecated attribute.
-WpaddedWarn if padding is included in a structure, either to align an element of the structure or to align the whole structure.
-Wpointer-arithWarn 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-declsWarn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing.
-WshadowWarn whenever a local variable shadows another local variable.
-Wsign-compare

-Wno-sign-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-prototypesWarn 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.)
-WtraditionalWarn about certain constructs that behave differently in traditional and ANSI C.
  • Macro arguments occurring within string constants in the macro body. These would substitute the argument in traditional C, but are part of the constant in ANSI C.
  • A function declared external in one block and then used after the end of the block.
  • A switch statement has an operand of type long.
  • A nonstatic function declaration follows a static one. This construct is not accepted by some traditional C compilers.
-WundefWarn if an undefined identifier is evaluated in an #if directive.
-Wwrite-stringsGive 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.