📄 invoke.texi
字号:
only 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 -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 -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+}, or @samp{-gdwarf}(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 in the native format (if that is supported),including GDB extensions if at all possible.@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 format (if that is supported).This is the format used by SDB on most System V Release 4 systems.@item -gdwarf+Produce debugging information in DWARF 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 -g@var{level}@itemx -ggdb@var{level}@itemx -gstabs@var{level}@itemx -gcoff@var{level}@itemx -gxcoff@var{level}@itemx -gdwarf@var{level}Request debugging information and also use @var{level} to specify howmuch information. The default level is 2.Level 1 produces minimal information, enough for making backtraces inparts of the program that you don't plan to debug. This includesdescriptions of functions and external variables, but no informationabout local variables and no line numbers.Level 3 includes extra information, such as all the macro definitionspresent in the program. Some debuggers support macro expansion whenyou use @samp{-g3}.@cindex @code{prof}@item -pGenerate extra code to write profile information suitable for theanalysis program @code{prof}. You must use this option when compilingthe source files you want data about, and you must also use it whenlinking.@cindex @code{gprof}@item -pgGenerate extra code to write profile information suitable for theanalysis program @code{gprof}. You must use this option when compilingthe source files you want data about, and you must also use it whenlinking.@cindex @code{tcov}@item -aGenerate extra code to write profile information for basic blocks, which willrecord the number of times each basic block is executed, the basic block startaddress, and the function name containing the basic block. If @samp{-g} isused, the line number and filename of the start of the basic block will also berecorded. If not overridden by the machine description, the default action isto append to the text file @file{bb.out}.This data could be analyzed by a program like @code{tcov}. Note,however, that the format of the data is not what @code{tcov} expects.Eventually GNU @code{gprof} should be extended to process this data.@item -d@var{letters}Says to make debugging dumps during compilation at times specified by@var{letters}. This is used for debugging the compiler. The file namesfor most of the dumps are made by appending a word to the source filename (e.g. @file{foo.c.rtl} or @file{foo.c.jump}). Here are thepossible letters for use in @var{letters}, and their meanings:@table @samp@item MDump all macro definitions, at the end of preprocessing, and write nooutput.@item NDump all macro names, at the end of preprocessing.@item DDump all macro definitions, at the end of preprocessing, in addition tonormal output.@item yDump debugging information during parsing, to standard error.@item rDump after RTL generation, to @file{@var{file}.rtl}.@item xJust generate RTL for a function instead of compiling it. Usually usedwith @samp{r}.@item jDump after first jump optimization, to @file{@var{file}.jump}.@item sDump after CSE (including the jump optimization that sometimesfollows CSE), to @file{@var{file}.cse}.@item LDump after loop optimization, to @file{@var{file}.loop}.@item tDump after the second CSE pass (including the jump optimization thatsometimes follows CSE), to @file{@var{file}.cse2}.@item fDump after flow analysis, to @file{@var{file}.flow}.@item cDump after instruction combination, to the file@file{@var{file}.combine}.@item SDump after the first instruction scheduling pass, to@file{@var{file}.sched}.@item lDump after local register allocation, to@file{@var{file}.lreg}.@item gDump after global register allocation, to@file{@var{file}.greg}.@item RDump after the second instruction scheduling pass, to@file{@var{file}.sched2}.@item JDump after last jump optimization, to @file{@var{file}.jump2}.@item dDump after delayed branch scheduling, to @file{@var{file}.dbr}.@item kDump after conversion from registers to stack, to @file{@var{file}.stack}.@item aProduce all the dumps listed above.@item mPrint statistics on memory usage, at the end of the run, tostandard error.@item pAnnotate the assembler output with a comment indicating whichpattern and alternative was used.@end table@item -fpretend-floatWhen running a cross-compiler, pretend that the target machine uses thesame floating point format as the host machine. This causes incorrectoutput of the actual floating constants, but the actual instructionsequence will probably be the same as GNU CC would make when running onthe target machine.@item -save-tempsStore the usual ``temporary'' intermediate files permanently; place themin the current directory and name them based on the source file. Thus,compiling @file{foo.c} with @samp{-c -save-temps} would produce files@file{foo.i} and @file{foo.s}, as well as @file{foo.o}.@item -print-file-name=@var{library}Print the full absolute name of the library file @var{library} thatwould be used when linking---and don't do anything else. With thisoption, GNU CC does not compile or link anything; it just prints thefile name.@item -print-prog-name=@var{program}Like @samp{-print-file-name}, but searches for a program such as @samp{cpp}.@item -print-libgcc-file-nameSame as @samp{-print-file-name=libgcc.a}.This is useful when you use @samp{-nostdlib} or @samp{-nodefaultlibs}but you do want to link with @file{libgcc.a}. You can do@examplegcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`@end example@item -print-search-dirsPrint the name of the configured installation directory and a list ofprogram and library directories gcc will search---and don't do anything else.This is useful when gcc prints the error message@samp{installation problem, cannot exec cpp: No such file or directory}.To resolve this you either need to put @file{cpp} and the other compilercomponents where gcc expects to find them, or you can set the environmentvariable @code{GCC_EXEC_PREFIX} to the directory where you installed them.Don't forget the trailing '/'.@xref{Environment Variables}.@end table@node Optimize Options@section Options That Control Optimization@cindex optimize options@cindex options, optimizationThese options control various sorts of optimizations:@table @code@item -O@itemx -O1Optimize. Optimizing compilation takes somewhat more time, and a lotmore memory for a large function.Without @samp{-O}, the compiler's goal is to reduce the cost ofcompilation and to make debugging produce the expected results.Statements are independent: if you stop the program with a breakpointbetween statements, you can then assign a new value to any variable orchange the program counter to any othe
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -