The K Desktop Environment

9.3. Compiler Warnings

The following gives a description about the Compiler warning options that can be set on page 3 of the project options dialog. The explanations are taken from the man page for GCC, egcs version 1.1.1. The warnings themselves are diagnostic messages that indicate that constructions may cause errors .

-Wall

Standard `-W' options combined.

-W

Compile with -W. This option sets options not included in -Wall which are very specific. Please read GCC-Info for more information.

-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.

-Wshadow

Warn whenever a local variable shadows another local variable .

-Wid-clash-LEN

Warn whenever two distinct identifiers match in the first len characters. This may help you prepare a program that will compile with certain obsolete, brain-damaged Compiler s.

-Wlarger-then-LEN

Warn whenever an object of larger than LEN bytes is defined.

-Wpointer-arith

Warn about anything that depends on the «size of» a function type or of void. GNU C assigns these types a size of 1, for convenience in calculations with void * pointers and pointers to functions.

-Wbad-function-cast

Warn whenever a function call is cast to a non-matching type. For example, warn if int malloc() is cast to anything *.

-Wcast-equal

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 *.

-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 * on machines where integers can only be accessed at two- or four-byte boundaries.

-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 can try to write into a string constant, but only if you have been very careful about using const in declaration s and prototypes. Otherwise, it will just be a nuisance; this is why we did not make `-Wall' request these warnings .

-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.

-Wsign-compare

Warn when a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned.

-Waggregate-return

Warn if any functions that return structures or unions are defined or called. (In languages where you can return an array, this also elicits a warning.)

-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. The aim is to detect global functions that fail to be declared in header files.

-Wmissing-declaration s

Warn if a global function is defined without a previous declaration . Do so even if the definition itself provides a prototype. Use this option to detect global functions that are not declared in header files. -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.

-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.

-Wnested-externs

Warn if an extern declaration is encountered within an function.

-Winline

Warn if a function can not be inlined, and either it was declared as inline, or else the -fin*line-functions option was given.

-Wold-style-cast

Warn if an old-style (C-style) cast is used within a program

-Woverloaded-virtual

(C++ only.) In a derived class, the definitions of virtual functions must match the type signature of a virtual function declared in the base class. Use this option to request warnings when a derived class declares a function that may be an erroneous attempt to define a virtual function: that is, warn when a function with the same name as a virtual function in the base class, but with a type signature that doesn't match any virtual functions from the base class.

-Wsynth

Warn when g++'s synthesis behavior does not match that of cfront.

make all warnings into errors

(-Werror) Treat warnings as errors ; abort compilation after any warning.

For a release of your project, it is recommended to enable -Wall.