📄 gcc.texinfo
字号:
@samp{PATH} environment variable.The run-time support file @file{gnulib} is also searched for usingthe @samp{-B} prefix, if needed. If it is not found there, the twostandard prefixes above are tried, and that is all. The file is leftout of the link if it is not found by those means. Most of the time,on most machines, you can do without it.You can get a similar result from the environment variable;@code{GCC_EXEC_PREFIX} if it is defined, its value is used as a prefixin the same way. If both the @samp{-B} option and the@code{GCC_EXEC_PREFIX} variable are present, the @samp{-B} option isused first and the environment variable value second.@item -b@var{prefix}The argument @var{prefix} is used as a second prefix for the compilerexecutables and libraries. This prefix is optional: the compiler trieseach file first with it, then without it. This prefix follows theprefix specified with @samp{-B} or the default prefixes.Thus, @samp{-bvax- -Bcc/} in the presence of environment variable@code{GCC_EXEC_PREFIX} with definition @file{/u/foo/} causes GNU CC totry the following file names for the preprocessor executable:@examplecc/vax-cppcc/cpp/u/foo/vax-cpp/u/foo/cpp/usr/local/lib/gcc-vax-cpp/usr/local/lib/gcc-cpp/usr/lib/gcc-vax-cpp/usr/lib/gcc-cpp@end example@end tableThese options control the details of C compilation itself.@table @samp@item -ansiSupport all ANSI standard C programs.This turns off certain features of GNU C that are incompatible withANSI C, such as the @code{asm}, @code{inline} and @code{typeof}keywords, and predefined macros such as @code{unix} and @code{vax}that identify the type of system you are using. It also enables theundesirable and rarely used ANSI trigraph feature.The alternate keywords @code{__asm__}, @code{__inline__} and@code{__typeof__} continue to work despite @samp{-ansi}. You would notwant to use them in an ANSI C program, of course, but it useful to putthem in header files that might be included in compilations done with@samp{-ansi}. Alternate predefined macros such as @code{__unix__} and@code{__vax__} are also available, with or without @samp{-ansi}.The @samp{-ansi} option does not cause non-ANSI programs to berejected gratuitously. For that, @samp{-pedantic} is required inaddition to @samp{-ansi}.The macro @code{__STRICT_ANSI__} is predefined when the @samp{-ansi}option is used. Some header files may notice this macro and refrainfrom declaring certain functions or defining certain macros that theANSI standard doesn't call for; this is to avoid interfering with anyprograms that might use these names for other things.@item -traditionalAttempt to support some aspects of traditional C compilers.Specifically:@itemize @bullet@itemAll @code{extern} declarations take effect globally even if theyare written inside of a function definition. This includes implicitdeclarations of functions.@itemThe keywords @code{typeof}, @code{inline}, @code{signed}, @code{const}and @code{volatile} are not recognized. (You can still use the alternativekeywords such as @code{__typeof__}, @code{__inline__}, and so on.)@itemComparisons between pointers and integers are always allowed.@itemInteger types @code{unsigned short} and @code{unsigned char} promoteto @code{unsigned int}.@itemOut-of-range floating point literals are not an error.@itemString ``constants'' are not necessarily constant; they are stored inwritable space, and identical looking constants are allocatedseparately.@itemAll automatic variables not declared @code{register} are preserved by@code{longjmp}. Ordinarily, GNU C follows ANSI C: automatic variablesnot declared @code{volatile} may be clobbered.@itemIn the preprocessor, comments convert to nothing at all, rather thanto a space. This allows traditional token concatenation.@itemIn the preprocessor, macro arguments are recognized within stringconstants in a macro definition (and their values are stringified,though without additional quote marks, when they appear in such acontext). The preprocessor always considers a string constant to endat a newline.@itemThe predefined macro @code{__STDC__} is not defined when you use@samp{-traditional}, but @code{__GNUC__} is (since the GNU extensionswhich @code{__GNUC__} indicates are not affected by@samp{-traditional}). If you need to write header files that workdifferently depending on whether @samp{-traditional} is in use, bytesting both of these predefined macros you can distinguish foursituations: GNU C, traditional GNU C, other ANSI C compilers, andother old C compilers.@end itemize@item -OOptimize. 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 other statement in the function andget exactly the results you would expect from the source code.Without @samp{-O}, only variables declared @code{register} areallocated in registers. The resulting compiled code is a little worsethan produced by PCC without @samp{-O}.With @samp{-O}, the compiler tries to reduce code size and executiontime.Some of the @samp{-f} options described below turn specific kinds ofoptimization on or off.@item -gProduce debugging information in the operating system's native format(for DBX or SDB). GDB also can work with this debugging information.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.@item -ggProduce debugging information in the old GDB format. This is obsolete.@item -wInhibit all warning messages.@item -WPrint extra warning messages for these events:@itemize @bullet@itemAn automatic variable is used without first being initialized.These warnings are possible only in optimizing compilation,because they require data flow information that is computed onlywhen optimizing. If you don't specify @samp{-O}, you simply won'tget these warnings.These warnings occur only for variables that are candidates forregister allocation. Therefore, they do not occur for a variable thatis declared @code{volatile}, or whose address is taken, or whose sizeis other than 1, 2, 4 or 8 bytes. Also, they do not occur forstructures, unions or arrays, even when they are in registers.Note that there may be no warning about a variable that is used onlyto compute a value that itself is never used, because suchcomputations may be deleted by data flow analysis before the warningsare printed.These warnings are made optional because GNU CC is not smartenough to see all the reasons why the code might be correctdespite appearing to have an error. Here is one example of howthis can happen:@example@{ int x; switch (y) @{ case 1: x = 1; break; case 2: x = 4; break; case 3: x = 5; @} foo (x);@}@end example@noindentIf the value of @code{y} is always 1, 2 or 3, then @code{x} isalways initialized, but GNU CC doesn't know this. Here isanother common case:@example@{ int save_y; if (change_y) save_y = y, y = new_y; @dots{} if (change_y) y = save_y;@}@end example@noindentThis has no bug because @code{save_y} is used only if it is set.Some spurious warnings can be avoided if you declare as@code{volatile} all the functions you use that never return.@xref{Function Attributes}.@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:@examplefoo (a)@{ if (a > 0) return a;@}@end exampleSpurious warnings can occur because GNU CC does not realize thatcertain functions (including @code{abort} and @code{longjmp})will never return.@itemAn expression-statement contains no side effects.@end itemizeIn the future, other useful warnings may also be enabled by thisoption.@item -WimplicitWarn whenever a function is implicitly declared.@item -Wreturn-typeWarn whenever a function is defined with a return-type that defaultsto @code{int}. Also warn about any @code{return} statement with noreturn-value in a function whose return-type is not @code{void}.@item -WunusedWarn whenever a local variable is unused aside from its declaration,whenever a function is declared static but never defined, and whenevera statement computes a result that is explicitly not used.@item -WswitchWarn whenever a @code{switch} statement has an index of enumeral typeand lacks a @code{case} for one or more of the named codes of thatenumeration. (The presence of a @code{default} label prevents thiswarning.) @code{case} labels outside the enumeration range alsoprovoke warnings when this option is used.@item -WcommentWarn whenever a comment-start sequence @samp{/*} appears in a comment.@item -WtrigraphsWarn if any trigraphs are encountered (assuming they are enabled).@item -WallAll of the above @samp{-W} options combined. These are all theoptions which pertain to usage that we recommend avoiding and that webelieve is easy to avoid, even in conjunction with macros.The other @samp{-W@dots{}} options below are not implied by @samp{-Wall}because certain kinds of useful macros are almost impossible to writewithout causing those warnings.@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 -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 -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 -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 -pGenerate extra code to write profile information suitable for theanalysis program @code{prof}.@item -pgGenerate extra code to write profile information suitable for theanalysis program @code{gprof}.@item -aGenerate extra code to write profile information for basic blocks, whichwill record the number of times each basic block is executed. This datacould be analyzed by a program like @code{tcov}. Note, however, thatthe format of the data is not what @code{tcov} expects. Eventually GNU@code{gprof} should be extended to process this data.@item -l@var{library}Search a standard list of directories for a library named@var{library}, which is actually a file named@file{lib@var{library}.a}. The linker uses this file as if ithad been specified precisely by name.The directories searched include several standard system directories
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -