?? invoke.texi
字號:
@cindex warning for reordering of member initializersWarn when the order of member initializers given in the code does notmatch the order in which they must be executed. For instance:@smallexamplestruct A @{ int i; int j; A(): j (0), i (1) @{ @}@};@end smallexampleHere the compiler will warn that the member initializers for @samp{i}and @samp{j} will be rearranged to match the declaration order of themembers.@item -Wtemplate-debugging@cindex template debuggingWhen using templates in a C++ program, warn if debugging is not yetfully available (C++ only).@item -WallAll of the above @samp{-W} options combined. This enables all thewarnings about constructions that some users consider questionable, andthat are easy to avoid (or modify to prevent the warning), even inconjunction with macros.@end tableThe following @samp{-W@dots{}} options are not implied by @samp{-Wall}.Some of them warn about constructions that users generally do notconsider questionable, but which occasionally you might wish to checkfor; others warn about constructions that are necessary or hard to avoidin some cases, and there is no simple way to modify the code to suppressthe warning.@table @code@item -WPrint extra warning messages for these events:@itemize @bullet@cindex @code{longjmp} warnings@itemA nonvolatile automatic variable might be changed by a call to@code{longjmp}. These warnings as well are possible only inoptimizing compilation.The compiler sees only the calls to @code{setjmp}. It cannot knowwhere @code{longjmp} will be called; in fact, a signal handler couldcall it at any point in the code. As a result, you may get a warningeven when there is in fact no problem because @code{longjmp} cannotin fact be called at the place which would cause a problem.@itemA function can return either with or without a value. (Fallingoff the end of the function body is considered returning withouta value.) For example, this function would evoke such awarning:@smallexample@groupfoo (a)@{ if (a > 0) return a;@}@end group@end smallexample@itemAn expression-statement or the left-hand side of a comma expressioncontains no side effects.To suppress the warning, cast the unused expression to void.For example, an expression such as @samp{x[i,j]} will cause a warning,but @samp{x[(void)i,j]} will not.@itemAn unsigned value is compared against zero with @samp{<} or @samp{<=}.@itemA comparison like @samp{x<=y<=z} appears; this is equivalent to@samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation fromthat of ordinary mathematical notation.@itemStorage-class specifiers like @code{static} are not the first things ina declaration. According to the C Standard, this usage is obsolescent.@itemIf @samp{-Wall} or @samp{-Wunused} is also specified, warn about unusedarguments.@itemA comparison between signed and unsigned values could produce anincorrect result when the signed value is converted to unsigned.(But do not warn if @samp{-Wno-sign-compare} is also specified.)@itemAn aggregate has a partly bracketed initializer.For example, the following code would evoke such a warning,because braces are missing around the initializer for @code{x.h}:@smallexamplestruct s @{ int f, g; @};struct t @{ struct s h; int i; @};struct t x = @{ 1, 2, 3 @};@end smallexample@end itemize@item -WtraditionalWarn about certain constructs that behave differently in traditional andANSI C.@itemize @bullet@itemMacro arguments occurring within string constants in the macro body.These would substitute the argument in traditional C, but are part ofthe constant in ANSI C.@itemA function declared external in one block and then used after the end ofthe block.@itemA @code{switch} statement has an operand of type @code{long}.@end itemize@item -WundefWarn if an undefined identifier is evaluated in an @samp{#if} directive.@item -WshadowWarn whenever a local variable shadows another local variable.@item -Wid-clash-@var{len}Warn whenever two distinct identifiers match in the first @var{len}characters. This may help you prepare a program that will compilewith certain obsolete, brain-damaged compilers.@item -Wlarger-than-@var{len}Warn whenever an object of larger than @var{len} bytes is defined.@item -Wpointer-arithWarn about anything that depends on the ``size of'' a function type orof @code{void}. GNU C assigns these types a size of 1, forconvenience in calculations with @code{void *} pointers and pointersto functions.@item -Wbad-function-castWarn whenever a function call is cast to a non-matching type.For example, warn if @code{int malloc()} is cast to @code{anything *}.@item -Wcast-qualWarn whenever a pointer is cast so as to remove a type qualifier fromthe target type. For example, warn if a @code{const char *} is castto an ordinary @code{char *}.@item -Wcast-alignWarn whenever a pointer is cast such that the required alignment of thetarget is increased. For example, warn if a @code{char *} is cast toan @code{int *} on machines where integers can only be accessed attwo- or four-byte boundaries.@item -Wwrite-stringsGive string constants the type @code{const char[@var{length}]} so thatcopying the address of one into a non-@code{const} @code{char *}pointer will get a warning. These warnings will help you find atcompile time code that can try to write into a string constant, butonly if you have been very careful about using @code{const} indeclarations and prototypes. Otherwise, it will just be a nuisance;this is why we did not make @samp{-Wall} request these warnings.@item -WconversionWarn if a prototype causes a type conversion that is different from whatwould happen to the same argument in the absence of a prototype. Thisincludes conversions of fixed point to floating and vice versa, andconversions changing the width or signedness of a fixed point argumentexcept when the same as the default promotion.Also, warn if a negative integer constant expression is implicitlyconverted to an unsigned type. For example, warn about the assignment@code{x = -1} if @code{x} is unsigned. But do not warn about explicitcasts like @code{(unsigned) -1}.@item -Wsign-compare@cindex warning for comparison of signed and unsigned values@cindex comparison of signed and unsigned values, warning@cindex signed and unsigned values, comparison warningWarn when a comparison between signed and unsigned values could producean incorrect result when the signed value is converted to unsigned.This warning is also enabled by @samp{-W}; to get the other warningsof @samp{-W} without this warning, use @samp{-W -Wno-sign-compare}.@item -Waggregate-returnWarn if any functions that return structures or unions are defined orcalled. (In languages where you can return an array, this also elicitsa warning.)@item -Wstrict-prototypesWarn if a function is declared or defined without specifying theargument types. (An old-style function definition is permitted withouta warning if preceded by a declaration which specifies the argumenttypes.)@item -Wmissing-prototypesWarn if a global function is defined without a previous prototypedeclaration. This warning is issued even if the definition itselfprovides a prototype. The aim is to detect global functions that failto be declared in header files.@item -Wmissing-declarationsWarn 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 inheader files.@item -Wredundant-declsWarn if anything is declared more than once in the same scope, even incases where multiple declaration is valid and changes nothing.@item -Wnested-externsWarn if an @code{extern} declaration is encountered within an function.@item -WinlineWarn if a function can not be inlined, and either it was declared as inline,or else the @samp{-finline-functions} option was given.@item -Wold-style-castWarn if an old-style (C-style) cast is used within a program.@item -Woverloaded-virtual@cindex overloaded virtual fn, warning@cindex warning for overloaded virtual fnWarn when a derived class function declaration may be an error indefining a virtual function (C++ only). In a derived class, thedefinitions of virtual functions must match the type signature of avirtual function declared in the base class. With this option, thecompiler warns when you define a function with the same name as avirtual function, but with a type signature that does not match anydeclarations from the base class.@item -Wsynth (C++ only)@cindex warning for synthesized methods@cindex synthesized methods, warningWarn when g++'s synthesis behavior does not match that of cfront. Forinstance:@smallexamplestruct A @{ operator int (); A& operator = (int);@};main ()@{ A a,b; a = b;@}@end smallexampleIn this example, g++ will synthesize a default @samp{A& operator =(const A&);}, while cfront will use the user-defined @samp{operator =}.@item -WerrorMake all warnings into errors.@end table@node Debugging Options@section Options for Debugging Your Program or GNU CC@cindex options, debugging@cindex debugging information optionsGNU CC has various special options that are used for debuggingeither your program or GCC:@table @code@item -gProduce debugging information in the operating system's native format(stabs, COFF, XCOFF, or DWARF). GDB can work with this debugginginformation.On most systems that use stabs format, @samp{-g} enables use of extradebugging information that only GDB can use; this extra informationmakes debugging work better in GDB but will probably make other debuggerscrash orrefuse to read the program. If you want to control for certain whetherto generate the extra information, use @samp{-gstabs+}, @samp{-gstabs},@samp{-gxcoff+}, @samp{-gxcoff}, @samp{-gdwarf-1+}, or @samp{-gdwarf-1}(see below).Unlike most other C compilers, GNU CC allows you to use @samp{-g} with@samp{-O}. The shortcuts taken by optimized code may occasionallyproduce surprising results: some variables you declared may not existat all; flow of control may briefly move where you did not expect it;some statements may not be executed because they compute constantresults or their values were already at hand; some statements mayexecute in different places because they were moved out of loops.Nevertheless it proves possible to debug optimized output. This makesit reasonable to use the optimizer for programs that might have bugs.The following options are useful when GNU CC is generated with thecapability for more than one debugging format.@item -ggdbProduce debugging information for use by GDB. This means to use themost expressive format available (DWARF 2, stabs, or the native formatif neither of those are supported), including GDB extensions if at allpossible.@item -gstabsProduce debugging information in stabs format (if that is supported),without GDB extensions. This is the format used by DBX on most BSDsystems. On MIPS, Alpha and System V Release 4 systems this optionproduces stabs debugging output which is not understood by DBX or SDB.On System V Release 4 systems this option requires the GNU assembler.@item -gstabs+Produce debugging information in stabs format (if that is supported),using GNU extensions understood only by the GNU debugger (GDB). Theuse of these extensions is likely to make other debuggers crash orrefuse to read the program.@item -gcoffProduce debugging information in COFF format (if that is supported).This is the format used by SDB on most System V systems prior toSystem V Release 4.@item -gxcoffProduce debugging information in XCOFF format (if that is supported).This is the format used by the DBX debugger on IBM RS/6000 systems.@item -gxcoff+Produce debugging information in XCOFF format (if that is supported),using GNU extensions understood only by the GNU debugger (GDB). Theuse of these extensions is likely to make other debuggers crash orrefuse to read the program, and may cause assemblers other than the GNUassembler (GAS) to fail with an error.@item -gdwarfProduce debugging information in DWARF version 1 format (if that is
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -