📄 gcc.1
字号:
.TH GCC 1 "28 November 1990" "Version 1.40".de BP.sp.ti -.2i\(**...SH NAMEgcc \- GNU project C Compiler.SH SYNOPSIS.B gcc[ options ] files.SH WARNINGThis man page is an extract of the documentation of the.I GNU C compilerand is limited to the meaning of the options..B It is not kept up to date.If you want to be certain of the informationbelow, check it in the manual "Using and Porting GCC". Refer to the Info file.B gcc.infoor the DVI file.B gcc.dviwhich are made from the Texinfo source file.BR gcc.texinfo ..SH DESCRIPTIONThe.I GNU C compileruses a command syntax much like the Unix C compiler.The.I gccprogram accepts options and file names as operands.Multiple single-letter options may.I notbe grouped:.B \-dris very different from.BR "\-d \-r" ..PWhen you invoke GNU CC, it normally does preprocessing, compilation,assembly and linking.File names which end in.B .care taken as C source to be preprocessed and compiled;file names ending in.B .iare taken as preprocessor output to be compiled;compiler output files plus any input files with names ending in.B .sare assembled;then the resulting object files, plus any other input files,are linked together to produce an executable..PCommand options allow you to stop this process at an intermediate stage.For example, the .B \-coption says not to run the linker.Then the output consists of object files output by the assembler..POther command options are passed on to one stage of processing.Some options control the preprocessor and others the compiler itself.Yet other options control the assembler and linker;these are not documented here, but you rarely need to use any of them..SH OPTIONSHere are the options to control the overall compilation process,including those that say whether to link, whether to assemble, and so on..TP.BI \-o " file"Place output in file.IR file .This applies regardless to whatever sort of output is being produced,whether it be an executable file, an object file,an assembler file or preprocessed C code..spIf .B \-ois not specified, the default is to put an executable file in.BR a.out ,the object file.IB source .cin.IB source .o\fR,an assembler file in.IB source .s\fR,and preprocessed C on standard output..TP.B \-cCompile or assemble the source files, but do not link.Produce object files with names made by replacing.B .cor.B .swith.B .oat the end of the input file names.Do nothing at all for object files specified as input..TP.B \-SCompile into assembler code but do not assemble.The assembler output file name is made by replacing.B .cwith.B .sat the end of the input file name.Do nothing at all for assembler source files orobject files specified as input..TP.B \-ERun only the C preprocessor.Preprocess all the C source files specified and outputthe results to standard output..TP.B \-vCompiler driver program prints the commands it executes as it runsthe preprocessor, compiler proper, assembler and linker.Some of these are directed to print their own version numbers..TP.B \-pipeUse pipes rather than temporary files for communication between thevarious stages of compilation.This fails to work on some systems where the assembler is unableto read from a pipe; but the GNU assembler has no trouble..TP.BI \-B prefixCompiler driver program tries.I prefixas a prefix for each program it tries to run.These programs are.IR cpp ,.IR cc1 ,.I asand.IR ld ..spFor each subprogram to be run, the compiler driver first tries the.B \-Bprefix, if any.If that name is not found, or if.B \-Bwas not specified, the driver tries two standard prefixes, which are.B /usr/lib/gcc-and.BR /usr/local/lib/gcc- .If neither of those results in a file name that is found, theunmodified program name is searched for using the directoriesspecified in your.B PATHenvironment variable..spThe run-time support file.B gnulibis also searched for using the.B \-Bprefix, if needed.If it is not found there, the two standard prefixes aboveare tried, and that is all.The file is left out of the link if it is not found by those means.Most of the time, on most machines, you can do without it..spYou can get a similar result from the environment variable.BR GCC_EXEC_PREFIX ;if it is defined, its value is used as a prefix in the same way.If both the.B \-Boption and the.B GCC_EXEC_PREFIXvariable are present, the.B \-Boption is used first and the environment variable value second..TP.BI -b prefixThe argument.I prefixis used as a second prefix for the compiler executables and libraries.This prefix is optional: the compiler tries each file first with it,then without it.This prefix follows the prefix specified with.B \-Bor the default prefixes..spThus,.B \-bvax- \-Bcc/in the presence of environment variable.B GCC_EXEC_PREFIXwith definition.B /u/foo/causes GNU CC to try the following file names for the preprocessor executable:.sp \fBcc/vax-cpp.br cc/cpp.br /u/foo/vax-cpp.br /u/foo/cpp.br /usr/local/lib/gcc-vax-cpp.br /usr/local/lib/gcc-cpp.br /usr/lib/gcc-vax-cpp.br /usr/lib/gcc-cpp\fR.PThese options control the details of C compilation itself..TP.B \-ansiSupport all ANSI standard C programs..spThis turns off certain features of GNU C that are incompatible withANSI C, such as the.BR asm ,.B inlineand.B typeofkeywords, and predefined macros such as.B unixand.B vaxthat identify the type of system you are using.It also enables the undesirable and rarely used ANSI trigraph feature..spThe alternate keywords.BR __asm__ ,.B __inline__and.B __typeof__continue to work despite.BR \-ansi .You would not want to use them in an ANSI C program, of course,but it useful to put them in header files that might be includedin compilations done with.BR \-ansi .Alternate predefined macros such as.B __unix__and.B __vax__are also available, with or without.BR \-ansi ..spThe.B \-ansioption does not cause non-ANSI programs to be rejected gratuitously.For that,.B \-pedanticis required in addition to.BR \-ansi ..spThe macro .B __STRICT_ANSI__is predefined when the.B \-ansioption is used.Some header files may notice this macro and refrain from declaringcertain functions or defining certain macros that the ANSI standarddoesn't call for; this is to avoid interfering with any programsthat might use these names for other things..TP.B \-traditionalAttempt to support some aspects of traditional C compilers.Specifically:.BPAll.B externdeclarations take effect globally even if they arewritten inside of a function definition.This includes implicit declarations of functions..BPThe keywords.BR typeof ,.BR inline ,.BR signed ,.B constand.B volatileare not recognized..BPComparisons between pointers and integers are always allowed..BPInteger types.B "unsigned short"and.B "unsigned char"promote to.BR "unsigned int" ..BPOut-of-range floating point literals are not an error..BPAll automatic variables not declared.B registerare preserved by.IR longjmp (3C).Ordinarily, GNU C follows ANSI C: automatic variables not declared.B volatilemay be clobbered..BPIn the preprocessor, comments convert to nothing at all,rather than to a space.This allows traditional token concatenation..BPIn the preprocessor, macro arguments are recognized within stringconstants in a macro definition (and their values are stringified, thoughwithout additional quote marks, when they appear in such a context).The preprocessor always considers a string constant to end at a newline..BPThe predefined macro.B __STDC__is not defined when you use.BR \-traditional ,but.B __GNUC__is (since the GNU extensions which.B __GNUC__indicates are not affected by.BR \-traditional ).If you need to write header files that work differently depending on whether.B \-traditionalis in use, by testing both of these predefined macros you can distinguishfour situations: GNU C, traditional GNU C, other ANSI C compilers, andother old C compilers..TP.B \-OOptimize.Optimizing compilation takes somewhat more time,and a lot more memory for a large function..spWithout.BR \-O ,the compiler's goal is to reduce the cost of compilation andto 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..spWithout.BR \-O ,only variables declared.B registerare allocated in registers.The resulting compiled code is a little worse than produced by PCC without.BR \-O ..spWith.BR \-O ,the compiler tries to reduce code size and execution time..spSome of the.B \-foptions described below turn specific kinds of optimization on or off..TP.B \-gProduce debugging information in the operating system'snative format (for DBX or SDB).GDB also can work with this debugging information..spUnlike most other C compilers, GNU CC allows you to use.B \-gwith.BR \-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 makes it reasonable to use the optimizer for programsthat might have bugs..TP.B \-wInhibit all warning messages..TP.B \-WPrint extra warning messages for these events:.BPAn automatic variable is used without first being initialized..spThese warnings are possible only in optimizing compilation,because they require data flow information that is computed onlywhen optimizing.If you don't specify.BR \-O ,you simply won't get these warnings..spThese warnings occur only for variables that are candidates forregister allocation.Therefore, they do not occur for a variable that is declared.BR volatile ,or whose address is taken, or whose size is other than 1, 2, 4 or 8 bytes.Also, they do not occur for structures, unions or arrays, even whenthey are in registers..spNote 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..spThese 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 how this can happen:.sp {.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 }.spIf the value of .I yis always 1, 2 or 3, then.I xis always initialized, but GNU CC doesn't know this.Here is another common case:.sp {.br \ \ int save_y;.br \ \ if (change_y) save_y = y, y = new_y;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -