⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 g77.texi

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
@cindex translation of user programs@cindex machine code@cindex code, machine@cindex mistakes@itemThey translate the user's program into instructionsa computer can carry out more quickly than it takesto translate the instructions in the first place.These instructions are called @dfn{machine code}---codedesigned to be efficiently translated and processedby a machine such as a computer.Humans usually aren't as good writing machine codeas they are at writing Fortran or C, becauseit is easy to make tiny mistakes writing machine code.When writing Fortran or C, it is easyto make big mistakes.@cindex debugger@cindex bugs, finding@cindex @code{gdb}, command@cindex commands, @code{gdb}@itemThey provide information in the generated machine codethat can make it easier to find bugs in the program(using a debugging tool, called a @dfn{debugger},such as @code{gdb}).@cindex libraries@cindex linking@cindex @code{ld} command@cindex commands, @code{ld}@itemThey locate and gather machine code already generatedto perform actions requested by statements inthe user's program.This machine code is organizedinto @dfn{libraries} and is located and gatheredduring the @dfn{link} phase of the compilationprocess.(Linking often is thought of as a separatestep, because it can be directly invoked via the@code{ld} command.However, the @code{g77} and @code{gcc}commands, as with most compiler commands, automaticallyperform the linking step by calling on @code{ld}directly, unless asked to not do so by the user.)@cindex language, incorrect use of@cindex incorrect use of language@itemThey attempt to diagnose cases where the user'sprogram contains incorrect usages of the language.The @dfn{diagnostics} produced by the compilerindicate the problem and the location in the user'ssource file where the problem was first noticed.The user can use this information to locate andfix the problem.@cindex diagnostics, incorrect@cindex incorrect diagnostics@cindex error messages, incorrect@cindex incorrect error messages(Sometimes an incorrect usageof the language leads to a situation where thecompiler can no longer make any sense of whatfollows---while a human might be able to---andthus ends up complaining about many ``problems''it encounters that, in fact, stem from just oneproblem, usually the first one reported.)@cindex warnings@cindex questionable instructions@itemThey attempt to diagnose cases where the user'sprogram contains a correct usage of the language,but instructs the computer to do something questionable.These diagnostics often are in the form of @dfn{warnings},instead of the @dfn{errors} that indicate incorrectusage of the language.@end itemizeHow these actions are performed is generally under thecontrol of the user.Using command-line options, the user can specifyhow persnickety the compiler is to be regardingthe program (whether to diagnose questionable usageof the language), how much time to spend makingthe generated machine code run faster, and so on.@cindex components of g77@cindex @code{g77}, components of@code{g77} consists of several components:@cindex @code{gcc}, command@cindex commands, @code{gcc}@itemize @bullet@itemA modified version of the @code{gcc} command, which also might beinstalled as the system's @code{cc} command.(In many cases, @code{cc} refers to thesystem's ``native'' C compiler, whichmight be a non-GNU compiler, or an older versionof @code{gcc} considered more stable or that isused to build the operating system kernel.)@cindex @code{g77}, command@cindex commands, @code{g77}@itemThe @code{g77} command itself, which also might be installed as thesystem's @code{f77} command.@cindex libg2c library@cindex libf2c library@cindex libraries, libf2c@cindex libraries, libg2c@cindex run-time, library@itemThe @code{libg2c} run-time library.This library contains the machine code needed to supportcapabilities of the Fortran language that are not directlyprovided by the machine code generated by the @code{g77}compilation phase.@code{libg2c} is just the unique name @code{g77} givesto its version of @code{libf2c} to distinguish it fromany copy of @code{libf2c} installed from @code{f2c}(or versions of @code{g77} that built @code{libf2c} underthat same name)on the system.The maintainer of @code{libf2c} currently is@email{dmg@@bell-labs.com}.@cindex @code{f771}, program@cindex programs, @code{f771}@cindex assembler@cindex @code{as} command@cindex commands, @code{as}@cindex assembly code@cindex code, assembly@itemThe compiler itself, internally named @code{f771}.Note that @code{f771} does not generate machine code directly---itgenerates @dfn{assembly code} that is a more readable formof machine code, leaving the conversion to actual machine codeto an @dfn{assembler}, usually named @code{as}.@end itemize@code{gcc} is often thought of as ``the C compiler'' only,but it does more than that.Based on command-line options and the names given for fileson the command line, @code{gcc} determines which actions to perform, includingpreprocessing, compiling (in a variety of possible languages), assembling,and linking.@cindex driver, gcc command as@cindex @code{gcc}, command as driver@cindex executable file@cindex files, executable@cindex cc1 program@cindex programs, cc1@cindex preprocessor@cindex cpp program@cindex programs, cppFor example, the command @samp{gcc foo.c} @dfn{drives} the file@file{foo.c} through the preprocessor @code{cpp}, thenthe C compiler (internally named@code{cc1}), then the assembler (usually @code{as}), then the linker(@code{ld}), producing an executable program named @file{a.out} (onUNIX systems).@cindex cc1plus program@cindex programs, cc1plusAs another example, the command @samp{gcc foo.cc} would do much the same as@samp{gcc foo.c}, but instead of using the C compiler named @code{cc1},@code{gcc} would use the C++ compiler (named @code{cc1plus}).@cindex @code{f771}, program@cindex programs, @code{f771}In a GNU Fortran installation, @code{gcc} recognizes Fortran sourcefiles by name just like it does C and C++ source files.It knows to use the Fortran compiler named @code{f771}, instead of@code{cc1} or @code{cc1plus}, to compile Fortran files.@cindex @code{gcc}, not recognizing Fortran source@cindex unrecognized file format@cindex file format not recognizedNon-Fortran-related operation of @code{gcc} is generallyunaffected by installing the GNU Fortran version of @code{gcc}.However, without the installed version of @code{gcc} being theGNU Fortran version, @code{gcc} will not be able to compileand link Fortran programs---and since @code{g77} uses @code{gcc}to do most of the actual work, neither will @code{g77}!@cindex @code{g77}, command@cindex commands, @code{g77}The @code{g77} command is essentially just a front-end forthe @code{gcc} command.Fortran users will normally use @code{g77} instead of @code{gcc},because @code{g77}knows how to specify the libraries needed to link with Fortran programs(@code{libg2c} and @code{lm}).@code{g77} can still compile and link programs andsource files written in other languages, just like @code{gcc}.@cindex printing version information@cindex version information, printingThe command @samp{g77 -v} is a quickway to display lots of version information for the various programsused to compile a typical preprocessed Fortran source file---thisproduces much more output than @samp{gcc -v} currently does.(If it produces an error message near the end of the output---diagnosticsfrom the linker, usually @code{ld}---you mighthave an out-of-date @code{libf2c} that improperly handlescomplex arithmetic.)In the output of this command, the line beginning @samp{GNU Fortran FrontEnd} identifies the version number of GNU Fortran; immediatelypreceding that line is a line identifying the version of @code{gcc}with which that version of @code{g77} was built.@cindex libf2c library@cindex libraries, libf2cThe @code{libf2c} library is distributed with GNU Fortran forthe convenience of its users, but is not part of GNU Fortran.It contains the proceduresneeded by Fortran programs while they are running.@cindex in-line code@cindex code, in-lineFor example, while code generated by @code{g77} is likelyto do additions, subtractions, and multiplications @dfn{in line}---inthe actual compiled code---it is not likely to do trigonometricfunctions this way.Instead, operations like trigonometricfunctions are compiled by the @code{f771} compiler(invoked by @code{g77} when compiling Fortran code) into machinecode that, when run, calls on functions in @code{libg2c}, so@code{libg2c} must be linked with almost every useful programhaving any component compiled by GNU Fortran.(As mentioned above, the @code{g77} command takescare of all this for you.)The @code{f771} program represents most of what is unique to GNU Fortran.While much of the @code{libg2c} component comes fromthe @code{libf2c} component of @code{f2c},a free Fortran-to-C converter distributed by Bellcore (AT&T),plus @code{libU77}, provided by Dave Love,and the @code{g77} command is just a small front-end to @code{gcc},@code{f771} is a combination of two ratherlarge chunks of code.@cindex GNU Back End (GBE)@cindex GBE@cindex @code{gcc}, back end@cindex back end, gcc@cindex code generatorOne chunk is the so-called @dfn{GNU Back End}, or GBE,which knows how to generate fast code for a wide variety of processors.The same GBE is used by the C, C++, and Fortran compiler programs @code{cc1},@code{cc1plus}, and @code{f771}, plus others.Often the GBE is referred to as the ``gcc back end'' oreven just ``gcc''---in this manual, the term GBE is usedwhenever the distinction is important.@cindex GNU Fortran Front End (FFE)@cindex FFE@cindex @code{g77}, front end@cindex front end, @code{g77}The other chunk of @code{f771} is themajority of what is unique about GNU Fortran---the code that knows howto interpret Fortran programs to determine what they are intending todo, and then communicate that knowledge to the GBE for actual compilationof those programs.This chunk is called the @dfn{Fortran Front End} (FFE).The @code{cc1} and @code{cc1plus} programs have their own front ends,for the C and C++ languages, respectively.These fronts ends are responsible for diagnosingincorrect usage of their respective languages by theprograms the process, and are responsible for most ofthe warnings about questionable constructs as well.(The GBE handles producing some warnings, like thoseconcerning possible references to undefined variables.)Because so much is shared among the compilers for various languages,much of the behavior and many of the user-selectable options for thesecompilers are similar.For example, diagnostics (error messages andwarnings) are similar in appearance; command-lineoptions like @samp{-Wall} have generally similar effects; and the qualityof generated code (in terms of speed and size) is roughly similar(since that work is done by the shared GBE).@node G77 and GCC@chapter Compile Fortran, C, or Other Programs@cindex compiling programs@cindex programs, compiling@cindex @code{gcc}, command@cindex commands, @code{gcc}A GNU Fortran installation includes a modified version of the @code{gcc}command.In a non-Fortran installation, @code{gcc} recognizes C, C++,and Objective-C source files.In a GNU Fortran installation, @code{gcc} also recognizes Fortran sourcefiles and accepts Fortran-specific command-line options, plus somecommand-line options that are designed to cater to Fortran usersbut apply to other languages as well.@xref{G++ and GCC,,Compile C; C++; or Objective-C,gcc,Using and Porting GNU CC},for information on the way different languages are handledby the GNU CC compiler (@code{gcc}).@cindex @code{g77}, command@cindex commands, @code{g77}Also provided as part of GNU Fortran is the @code{g77} command.The @code{g77} command is designed to make compiling and linking Fortranprograms somewhat easier than when using the @code{gcc} command forthese tasks.It does this by analyzing the command line somewhat and changing itappropriately before submitting it to the @code{gcc} command.@cindex -v option@cindex @code{g77} options, -v@cindex options, -vUse the @samp{-v} option with @code{g77}to see what is going on---the first line of output is the invocationof the @code{gcc} command.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -