📄 gcc.1
字号:
\&\|' except that the macro arguments and contents are omitted.Only `\|\c.B #define \c.I name\c\&\c\&\|' is included in the output..PP.SH LINKER OPTIONSThese options come into play when the compiler links object files intoan executable output file. They are meaningless if the compiler isnot doing a link step..TP.I object-file-nameA file name that does not end in a special recognized suffix isconsidered to name an object file or library. (Object files aredistinguished from libraries by the linker according to the filecontents.) If GCC does a link step, these object files are used as inputto the linker..TP.BI \-l library\c\&Use the library named \c.I library\c\& when linking.The linker searches a standard list of directories for the library,which is actually a file named `\|\c.B lib\c.I library\c\&.a\c\&\|'. The linkerthen uses this file as if it had been specified precisely by name.The directories searched include several standard system directoriesplus any that you specify with `\|\c.B \-L\c\&\|'.Normally the files found this way are library files\(em\&archive fileswhose members are object files. The linker handles an archive file byscanning through it for members which define symbols that have so farbeen referenced but not defined. However, if the linker finds anordinary object file rather than a library, the object file is linkedin the usual fashion. The only difference between using an `\|\c.B \-l\c\&\|' option and specifying a filename is that `\|\c.B \-l\c\&\|' surrounds .I librarywith `\|\c.B lib\c\&\|' and `\|\c.B .a\c\&\|' and searches several directories..TP.B \-nostdlibDon't use the standard system libraries and startup files when linking.Only the files you specify will be passed to the linker..TP.B \-staticOn systems that support dynamic linking, this prevents linking with the sharedlibraries. On other systems, this option has no effect..PP.SH DIRECTORY OPTIONSThese options specify directories to search for header files, forlibraries and for parts of the compiler:.TP.BI "\-I" "dir"\c\&Append directory \c.I dir\c\& to the list of directories searched for include files..TP.B \-I\-Any directories you specify with `\|\c.B \-I\c\&\|' options before the `\|\c.B \-I\-\c\&\|'option are searched only for the case of `\|\c.B #include "\c.I file\c.B\&"\c\&\|';they are not searched for `\|\c.B #include <\c.I file\c\&>\c\&\|'.If additional directories are specified with `\|\c.B \-I\c\&\|' options afterthe `\|\c.B \-I\-\c\&\|', these directories are searched for all `\|\c.B #include\c\&\|'directives. (Ordinarily \c.I all\c\& `\|\c.B \-I\c\&\|' directories are usedthis way.)In addition, the `\|\c.B \-I\-\c\&\|' option inhibits the use of the currentdirectory (where the current input file came from) as the first searchdirectory for `\|\c.B #include "\c.I file\c.B\&"\c\&\|'. There is no way tooverride this effect of `\|\c.B \-I\-\c\&\|'. With `\|\c.B \-I.\c\&\|' you can specifysearching the directory which was current when the compiler wasinvoked. That is not exactly the same as what the preprocessor doesby default, but it is often satisfactory.`\|\c.B \-I\-\c\&\|' does not inhibit the use of the standard system directoriesfor header files. Thus, `\|\c.B \-I\-\c\&\|' and `\|\c.B \-nostdinc\c\&\|' areindependent..TP.BI "\-L" "dir"\c\&Add directory \c.I dir\c\& to the list of directories to be searchedfor `\|\c.B \-l\c\&\|'..TP.BI "\-B" "prefix"\c\&This option specifies where to find the executables, libraries anddata files of the compiler itself.The compiler driver program runs one or more of the subprograms`\|\c.B cpp\c\&\|', `\|\c.B cc1\c\&\|' (or, for C++, `\|\c.B cc1plus\c\&\|'), `\|\c.B as\c\&\|' and `\|\c.B ld\c\&\|'. It tries\c.I prefix\c\& as a prefix for each program it tries to run, both with andwithout `\|\c.B \c.I machine\c\&/\c.I version\c\&/\c\&\|'.For each subprogram to be run, the compiler driver first tries the`\|\c.B \-B\c\&\|' prefix, if any. If that name is not found, or if `\|\c.B \-B\c\&\|'was not specified, the driver tries two standard prefixes, which are`\|\c.B /usr/lib/gcc/\c\&\|' and `\|\c.B /usr/local/lib/gcc-lib/\c\&\|'. If neither ofthose results in a file name that is found, the compiler driversearches for the unmodified programname, using the directories specified in your`\|\c.B PATH\c\&\|' environment variable.The run-time support file `\|\c.B libgcc.a\c\&\|' is also searched for using the`\|\c.B \-B\c\&\|' 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, `\|\c.B libgcc.a\c\&\|' is not actually necessary.You can get a similar result from the environment variable\c.B GCC_EXEC_PREFIX\c\&; if it is defined, its value is used as a prefixin the same way. If both the `\|\c.B \-B\c\&\|' option and the\c.B GCC_EXEC_PREFIX\c\& variable are present, the `\|\c.B \-B\c\&\|' option isused first and the environment variable value second..PP.SH WARNING OPTIONSWarnings are diagnostic messages that report constructions whichare not inherently erroneous but which are risky or suggest theremay have been an error.These options control the amount and kinds of warnings produced by GNUCC:.TP.B \-fsyntax\-onlyCheck the code for syntax errors, but don't emit any output..TP.B \-wInhibit all warning messages..TP.B \-pedanticIssue all the warnings demanded by strict ANSI standard C; rejectall programs that use forbidden extensions.Valid ANSI standard C programs should compile properly with or withoutthis option (though a rare few will require `\|\c.B \-ansi\c\&\|'). However,without this option, certain GNU extensions and traditional C featuresare supported as well. With this option, they are rejected. There isno reason to \c.I use\c\& this option; it exists only to satisfy pedants.`\|\c.B \-pedantic\c\&\|' does not cause warning messages for use of thealternate keywords whose names begin and end with `\|\c.B __\c\&\|'. Pedanticwarnings are also disabled in the expression that follows\c.B __extension__\c\&. However, only system header files should usethese escape routes; application programs should avoid them..TP.B \-pedantic\-errorsLike `\|\c.B \-pedantic\c\&\|', except that errors are produced rather thanwarnings..TP.B \-WPrint extra warning messages for these events:.TP\ \ \ \(buA nonvolatile automatic variable might be changed by a call to\c.B longjmp\c\&. These warnings are possible only inoptimizing compilation.The compiler sees only the calls to \c.B setjmp\c\&. It cannot knowwhere \c.B longjmp\c\& 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 \c.B longjmp\c\& cannotin fact be called at the place which would cause a problem..TP\ \ \ \(buA 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:.sp.brfoo\ (a).br{.br\ \ if\ (a\ >\ 0).br\ \ \ \ return\ a;.br}.br.spSpurious warnings can occur because GNU CC does not realize thatcertain functions (including \c.B abort\c\& and \c.B longjmp\c\&)will never return..TP\ \ \ \(buAn expression-statement contains no side effects..TP\ \ \ \(buAn unsigned value is compared against zero with `\|\c.B >\c\&\|' or `\|\c.B <=\c\&\|'..PP.TP.B \-WimplicitWarn whenever a function or parameter is implicitly declared..TP.B \-Wreturn\-typeWarn whenever a function is defined with a return-type that defaultsto \c.B int\c\&. Also warn about any \c.B return\c\& statement with noreturn-value in a function whose return-type is not \c.B void\c\&..TP.B \-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..TP.B \-WswitchWarn whenever a \c.B switch\c\& statement has an index of enumeral typeand lacks a \c.B case\c\& for one or more of the named codes of thatenumeration. (The presence of a \c.B default\c\& label prevents thiswarning.) \c.B case\c\& labels outside the enumeration range alsoprovoke warnings when this option is used..TP.B \-WcommentWarn whenever a comment-start sequence `\|\c.B /*\c\&\|' appears in a comment..TP.B \-WtrigraphsWarn if any trigraphs are encountered (assuming they are enabled)..TP.B \-WformatCheck calls to \c.B printf\c\& and \c.B scanf\c\&, etc., to make sure thatthe arguments supplied have types appropriate to the format stringspecified..TP.B \-WuninitializedAn 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 `\|\c.B \-O\c\&\|', 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 \c.B volatile\c\&, 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:.sp.br{.br\ \ int\ x;.br\ \ switch\ (y).br\ \ \ \ {.br\ \ \ \ case\ 1:\ x\ =\ 1;.br\ \ \ \ \ \ break;.br\ \ \ \ case\ 2:\ x\ =\ 4;.br\ \ \ \ \ \ break;.br\ \ \ \ case\ 3:\ x\ =\ 5;.br\ \ \ \ }.br\ \ foo\ (x);.br}.br.spIf the value of \c.B y\c\& is always 1, 2 or 3, then \c.B x\c\& isalways initialized, but GNU CC doesn't know this. Here isanother common case:.sp.br{.br\ \ int\ save_y;.br\ \ if\ (change_y)\ save_y\ =\ y,\ y\ =\ new_y;.br\ \ .\|.\|..br\ \ if\ (change_y)\ y\ =\ save_y;.br}.br.spThis has no bug because \c.B save_y\c\& is used only if it is set.Some spurious warnings can be avoided if you declare as\c.B volatile\c\& all the functions you use that never return..TP.B \-WparenthesesWarn if parentheses are omitted in certain contexts..TP.B \-WallAll of the above `\|\c.B \-W\c\&\|' options combined. These are all theoptions which pertain to usage that we recommend avoiding and that webelieve are easy to avoid, even in conjunction with macros..PPThe remaining `\|\c.B \-W.\|.\|.\c\&\|' options are not implied by `\|\c.B \-Wall\c\&\|'because they warn about constructions that we consider reasonable touse, on occasion, in clean programs..TP.B \-WtraditionalWarn about certain constructs that behave differently in traditional andANSI C..TP\ \ \ \(buMacro 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..TP\ \ \ \(buA function declared external in one block and then used after the end ofthe block..TP\ \ \ \(buA \c.B switch\c\& statement has an operand of type \c.B long\c\&..PP.TP.B \-WshadowWarn whenever a local variable shadows another local variable..TP.BI "\-Wid\-clash\-" "len"\c\&Warn whenever two distinct identifiers match in the first \c.I len\c\&characters. This may help you prepare a program that will compilewith certain obsolete, brain-damaged compilers..TP.B \-Wpointer\-arithWarn about anything that depends on the ``size of'' a function type orof \c.B void\c\&. GNU C assigns these types a size of 1, forconvenience in calculations with \c.B void *\c\& pointers and pointersto functions..TP.B \-Wcast\-qualWarn whenever a pointer is cast so as to remove a type qualifier fromthe target type. For example, warn if a \c.B const char *\c\& is castto an ordinary \c.B char *\c\&..TP.B \-Wcast\-alignWarn whenever a pointer is cast such that the required alignment of thetarget is increased. For example, warn if a \c.B char *\c\& is cast toan \c.B int *\c\& on machines where integers can only be accessed attwo- or four-byte boundaries..TP.B \-Wwrite\-stringsGive string constants the type \c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -