C programming under Linux
ELF and A.out
Under Linux, there are two executables: ELF and A.out. It is possible that your Linux only supports one, there may be two kinds of support. Run the command file, if the command output contains ELF, support ELF, if you include Linux / i386, you support A.out.
GCC version
Use the following command to know its version:
GCC -V
Directory structure after GCC installation
/ usr / lib / gcc-lib / target / version / (and subdirectory) compiler is in this directory.
/ USR / BIN / GCC can be executed from the command line in this directory.
/ USR / TARGET / (BIN | LIB | Include) / library and header files in this directory.
/ lib /, / usr / libs and other directories, the library of the system is in these directories.
Symbol definition
Use the -v switch to see the symbol defined by the GCC. See the following examples:
$ echo 'main () {Printf ("Hello World");}' | gcc -e -v -
Reading Specs from /usr/lib/gcc-lib/i486-box-linux/2.7.2/specs
GCC Version 2.7.2
/usr/lib/gcc-lib/i486-box-linux/2.7.2/cpp -lang-c -v -undef
-D__gnuc __ = 2 -d__gnuc_minor __ = 7 -d__elf__ -dunix -di386 -dlinux
-D__elf__ -d__unix__ -d__i386__ -d__linux__ -d__unix -d__i386
-D__linux -asystem (unix) -asystem (pOSIX) -Acpu (i386)
-AMACHINE (i386) -D__i486__
GCC compiler introduction
Typically followed by some options and file names using the GCC compiler. The basic usage of the GCC command is as follows:
GCC [Options] [filenames]
Option Specifies how the compiler is compiled.
GCC option
GCC has 100 compilation options. Many of these options may never be used, but some major options will always encounter. A lot of GCC
Options include more than one character, so you must specify your respective hyphens for each option. For example, the following two commands are different:
GCC -P -G Test.c
GCC -PG Test.c
The first command tells the GCC to build a profile information for the PROF command and add the debug information to the executable file when compiling TEST.C. The second command only tells GCC
Establish a profiling information for the gprof command.
When there is no option, GCC generates an executable named A.out.
Use the -o compilation option to name it with the specified file name with the executable file. For example, compiling a C program called Count.c into an executable called count,
To enter the command like this:
GCC -O count country.c
The -c option tells GCC to compile source code as a target code. The target code file established by the GCC has a .o extension.
The -s compilation option tells GCC to stop compiling after the assembly language file is generated for C code. The default extension of the assembly language file generated by the GCC is .S.
The -e option indicates that the compiler is only preprocessing the input file. When this option is used, the output of the preprocessor is sent to the standard output instead of being stored in the file.
When compiling C code with GCC, it will try to complete compilation with the least amount of time and make the compiled code easy to debug.
Easy to debug means that the compiled code has not been optimized. If necessary, you need to allow the compiler to optimize the code.
The -o option tells the GCC to optimize the source code. These optimizations will make the program faster in most cases. -O2 option tells GCC to generate as small and as fast as possible. -O2 option will make compiled speeds slower than using -O, but the usual code execution speed will be faster.
GCC supports several commissioning and profiling options, often -g and -pg.
The -g option tells the GCC to generate debugging information that can be used by the GNU debugger to debug your program. GCC provides a number of features that have nothing in many other C compilers, you can make it in GCC
-g and -O (generated optimized code) are used.
The -pg option tells GCC to add additional code in the compiled program. When running the program, generate the profiling information for Gprof to display the time consumption of your program.
Debug GCC program with GDB
Linux contains a GNU debugger called GDB. The internal structure and memory usage of the program can be observed when the program is running. The following is some of the features provided by GDB:
Monitor the value of variables in the program
Set breakpoints to stop execution on the specified code line.
Perform code of one row
In order to use the GDB debugger, compiling is a must specify the debug option. Type GDB on the command line and press Enter to run GDB. If everything is normal, GDB
Will be started and displayed on the screen:
GDB IS Free Software and You Are Welcome To Distribute Copies of It Under
CERTAIN CONDitions; Type "show copying" to see the conditions.
There Is Absolutely No Warranty for GDB; Type "Show Warranty" for Details.
GDB 4.14 (I486-SLAKWARE-Linux), Copyright 1995 Free Software Foundation, Inc.
(GDB)
Many options can be added when GDB is started. You can also specify the program to be debugged directly after this command.
GDB
GDB basic order
GDB supports a lot of commands that are loaded from simple files to complex commands that allow checking the stack contents called. The following table lists some of the commands you use when using GDB debugging.
Command description
File loads the executable you want to debug
Kill terminates the program being debugging
List lists part of the source code generating the execution file
NEXT executes a source code but does not enter the function inside
Step executes a row source code and enters the function inside
Run executes the current debugged program
Quit termination GDB
Watch makes you monitor the value of a variable, regardless of when it is changed.
Break sets breakpoints in the code, which will hang up the program when it is executed here.
Make allows you to re-generate executables without exiting GDB.
Shell will execute a unix shell command without leaving GDB
GDB application example
The program that will be debugging is listed, which is called Greeting, showing a simple greeting, and listed it in the back sequence.
#include
Main ()
{
Char my_string [] = "Hello there";
MY_PRINT (my_string);
MY_PRINT2 (my_string);
}
void my_print (char * string)
{
Printf ("THE STRING IS% S", String;
}
Void my_print2 (char * string)
{
Char * string2;
Int size, i;
SIZE = Strlen (String);
String2 = (char *) Malloc (SIZE 1);
For (i = 0; i String2 [Size 1] = `0 '; Printf ("THE STRING Printed Backward IS% S", String2); } Compile this program with the following command: GCC -O -G Test Test.c Run the compiled program, display as follows: The string is hello there The String Printed Backward IS The first line of output is correct, but the second line of printing is not what we expect. The output we envisage should be: The String Printed Backward Is Ereht Olleh For some reason, my_print2 functions do not work properly. Use GDB to see where the problem is, first type the following command: GDB GRETING If you forget to pass the program to debug as a parameter to GDB, you can load it with a file command at the GDB prompt: (GDB) File Greeting This command loads the Greeting executable, just like the start GDB is loaded in the GDB command line. At this time, you can run Greeting with GDB's Run command. When it is running in GDB, the result is about like this: (GDB) RUN Starting program: / root / greeting The string is hello there The String Printed Backward IS Program evted with code 041 This output is the same as the result of running outside the GDB. The problem is, why don't you work in the reverse order? In order to find the crux, we can play in the MY_PRINT2 function. After the statement, set a breakpoint, the specific method is to type the list command three times in the GDB prompt, list the source code: (GDB) List (GDB) List (GDB) List The output of the first type is as follows: 1 #include 2 3 main () 4 { 5 char my_string [] = "Hello there"; 6 7 my_print (my_string); 8 my_print2 (my_string); 9 } 10 If you press Enter, GDB will execute a list command, give the following output: 11 my_print (char * string) 12 { 13 Printf ("THE STRING IS% S", String; 14} 15 16 my_print2 (char * string) 17 { 18 char * string2; 19 Int size, i; 20 Pressing a cycle will list the remaining parts of the Greeting program: 21 size = strlen (String); 22 string2 = (char *) Malloc (SIZE 1); 23 for (i = 0; i 24 string2 [size - i] = String [i]; 25 string2 [size 1] = `0 '; 26 Printf ("THE STRING Printed Backward IS% S", String2); 27} Based on the source program listed, you can see where you want to break points on, on line 24, type the following command to set breakpoints under the GDB command line prompt: (GDB) Break 24 The result of this command is as follows: Breakpoint 1 AT 0x139: File Greeting.c, Line 24 (GDB) Now type the RUN command, will generate the following output: Starting program: / root / greeting The string is hello there BreakPoint 1, My_Print2 (String = 0xBfffdc4 "Hello there") at Greeting.c: 24 24 string2 [size-i] = string [i] You can see how the error is generated by setting an observation point of the value of the string2 [size - i] variable, the practice is to type: (gdb) Watch string2 [size - i] The result is as follows: WatchPoint 2: String2 [size - i] Now you can use the next command to perform the for loop for a step: (GDB) Next After the first cycle, GDB tells us that the value of string2 [size - i] is `h`. This is the result after executing the next command: WatchPoint 2, String2 [Size - I] Old value = 0 `000 ' New value = 104 `h ' MY_PRINT2 (String = 0xBfffdc4 "Hello there") at Greeting.c: 23 23 for (i = 0; i This value is expected. The result of the subsequent cycle is correct. When i = 10, the value of expression string2 [size - i] is equal to `E`, Size - i The value is equal to 1, and the last character has been copied to the new string. If you do the loop, you will see that there is no value to assign to string2 [0], and it is the first character of the new stroke, because Malloc The function initials them as empty (NULL) characters when allocating memory. So the first characters of String2 are empty characters. So I found why there is no output when printing string2. It is easy to find out where the problem is found, it is easy to fix this error. Change the offset of the first character in the code to String2 to Size - 1 instead of size. This is because The String2 is 12, but the start offset is 0, the characters in the string from the offset amount 0 to the offset amount 10, the offset amount 11 is empty characters. In order to make the code work properly, there are many modifications. One is a variable that is a specific size of the actual size than the string, which is the program of this method. #include Main () { Char my_string [] = "Hello there"; MY_PRINT (my_string); MY_PRINT2 (my_string); } MY_PRINT (Char * String) { Printf ("THE STRING IS% S", String; } MY_PRINT2 (Char * String) { Char * string2; Int size, size2, i; SIZE = Strlen (String); Size2 = Size -1; String2 = (char *) Malloc (SIZE 1); For (i = 0; i String2 [Size2 - I] = String [i]; string2 [size] = `0 '; Printf ("THE STRING Printed Backward IS% S", String2); } Two Linux Shell Programming Shell programming is a program that contains a series of UNIX commands that can be run on the command line. Use the following command to execute a shell program: method one $ SH cmd.file Second $. cmd.file; Art $ chmod u x cmd.file $ cmd.file How to create and run a shell script In an editor, write a series of UNIX commands, for example: Echo this is a shell program Echo Today I am Going To ECHO $ 1 $ 2 $ 3 $ 4 $ 5 $ 6 $ 7 $ 8 $ 9 Save this file and name EX1. Then use the following command "CHMOD 700 EX1 ", turn this file to an executable file. Once you have finished the above steps. If you want to see this file, what results will appear, you can type in the command line: EX1 Coffee Bar in HANGzhou. The last line in the above program is to read the word in the ex1 command, and the second, etc. $ 1 represents the first word, $ 2 represents the second one. It can be seen that the purpose of the shell program is to batch commands to complete some more complex work. Different shells have different startup files, such as: Bash: .profile sh: .profile Csh: .cshrc TCSH: .cshrc Zsh: $ zdotdir / .zprofile and / or $ zdotdir / .zshrc All these startup files are read into .login and .logout files. Shell program design Comment Operator "#" introduces a comment. IF operator grammar IF [Conditional Expression] THEN Command sequence Fi or IF [Conditional Expression] THEN Command sequence Else Command sequence Fi Numerical operator = Equal to -N is not equal to -gt is greater than -lt is less than -LE is less than or equal EXIT command Used to end the shell script. You can bring a return value. EXPR command As a parameter and arithmetic operator, the result is calculated, and it returns its standard output. $ EXPR 4 5 9 $ The legal arithmetic operator has , -, *, / and%. Before * and / before, it must be replaced with a reverse slash, which has been prevented by the shell first interpretation. FOR operator loop statement. grammar: For $ Environment Variable IN string table DO Statement sequence DONE While operator loop statement. grammar: While [Condition Expression] DO Statement sequence DONE Case operator Condition control statement. grammar: Case $ Environment Variable in Constant 1) Statement sequence 1 ; Constant 2) Statement sequence 2 ; ... Constant n) Statement series N ; ESAC Command line $ # Command line variables for the script; $ * All command line variable yuan; Location $ 0 command itself $ 1 The first command line varies; $ 2 Second command line Shell function The shell function is defined by the following form FuncName () { Command sequence } Call FuncName Arg1 Arg2 / 2 / GCC manual and common command line GCC User Manual Author: Clock 1. Introduction The English version of the GCC compiler is very comprehensive, and the structure is also very perfect, but there is no Chinese version. I read the main content of the GCC compiler this time, the content of the manual is structured. Sex an understanding, it is considered necessary to organize this reading content and prepare for future work. Since I read this English manual is only structural. Therefore, there are many places that don't look, so I can only write some part of this document. For the place where you need more understanding, you will add content to this document, and the content that needs to add is mainly compiled. Switch. 2. GCC function introduction The GCC compiler completes the conversion of target code running from C, C , Objective-C, running on a specific CPU hardware (this is the task that needs to be completed). The source files that GCC can process are divided into C, C , Objective-C, assembly language, etc. For these source files, labeled them with their suffix names. The suffix that GCC can handle is: a. * .c * .c (C language) b. * .cxx * .cc (C language) c. * .m (object-oriented C) d. * .i (pre-processed C language source file) e. * .ii (pre-processed C language source file) f. * .s * .s (assembly language) h. * .h (header) The target file can be: a. * .o compiled target files b. * .a library file The compiler divides the task of compiling the target code into the following steps: a. Preprocessing, the pre-processing command scan is completed; b. Compile, compile the pre-processed results into compilation or target modules; c. Compilation, edip the compiled results into the target code module on the specific CPU; d. Connect, connect multiple target code modules to generate a large target module; 3. GCC switch The GCC running switch is divided into 11 categories, which is the operation of the GCC program from 11 aspects to achieve specific compilation purposes. 3.1. Global Switch (Overall Options) The global switch is used to control the operation of the four steps of the GCC in the "GCC function introduction", in the default, these four steps are executed, but when some global switch is given, these steps The execution will be stopped in one step, which creates intermediate results, for example, may simply need the result of the pre-processing in the middle or assembled files (such as the intended purpose to see how the assembly language on a CPU). 3.1.1. -X Language For the source file, what language is written, can be launched by the subscripted suffix, or this switch can also be used. Specifying the language written in the input file, Language can be the following a. c b. Objective-c c. c-header d. c E.cpp-output F.assembler G.assembler-with-cpp 3.1.2.-x None Turn off the -x switch introduced in the previous section. 3.1.3. -C Compile to the source file target code, do not connect the action. 3.1.4. -S Compile the source file into assembly code, do not make assembly and connections. 3.1.5. -E The result output only after the source file is preprocessed. Do not do compile, assembly, and connection action. 3.1.6. -O file Indicates the output file name is file. 3.1.7. -V The output information of the entire compilation process is printed. 3.1.8.-Pipe Since GCC's work is done, it is necessary to generate temporary files during the process, and use -pipe to replace temporary files with pipelines. 3.2. Language Options Used to handle and language-related control switches. 3.2.1.-ANSI This switch allows the GCC compiler to turn off all GNU compiler features, allowing your programs to be compatible with ANSI standards. In addition to the above switches, there are still many language-related switches. If you encounter it in future work, it is not too late! 3.3. Preprocessor Options The switches used to control the pre-processes. 3.3.1. -Include file Before compiling, put the file into it, which is equivalent to adding a #include 3.3.2. -Imacros file Like -inClude file. However, this document is only used in specific compilation, and the value is used to define a macro in the File file. 3.3.3. -Nostdinc Remove the standard C language header file search path in the file path of Include, such as the stdio.h file is placed under the standard header file search path. 3.3.4. -Nostdinc Also, just remove the header file search path of the standard C language. 3.3.5. -C Use the-E parameter. Let the results after pretreatment, keep your comment, let people read it better. 3.3.6. -Dmacro Define MacRo as a string '1'. 3.3.7. -Dmacro = DEFN Define MACRO as DEFN. 3.3.8. -Umacro Cancel the definition of Macro. In addition to the above switches, there are still many pretreatment related switches. If you encounter it in the future work, it is not too late! 3.4. Assembler Option The switch used to control assembly behavior. 3.4.1. -Wa, option Give Option as the switch to the assembler. If there is a comma in Option, it is handled as a few lines. 3.5. Linker Options Switch options used to control the connection process. 3.5.1. Object-file-name 3.5.2. -Llibrary Connect the library file switch. For example, -LUGL, the program is connected to the libugl.a file. 3.5.3. -Lobjc This switch is used in library file processing of object-oriented C language files. 3.5.4. -Nostartfiles Do not connect the system-related startup code when the connection is connected. 3.5.5. -Nostdlib Do not connect the system-related startup files and system-related libraries when they are connected. 3.5.6. -Static A dynamic connection is supported on some systems, this switch does not allow dynamic connections. 3.5.7. -Shared Generate a target module that can be shared by other programs. There are still some connections related to the switch, and then make it again. 3.6. Directory Related Switch (Directory Options) Used to define the switch related to the directory operation. 3.6.1. -IDIR Macro INCLUDE needs to search for a directory. 3.6.2.-i- Similar to the -i switch. 3.6.3.-LDIR The path to the library file (* .a). There are still a lot of switches related to the directory, and it needs to be added later. 3.7. Warning switch (WARNING OPTIONS) Switches related to warning processing. 3.7.1.-fsyntax-only Only the syntax errors in the code are checked, but there is no output. 3.7.2. -W Prohibit all warning information to print out. 3.7.3. -Wno-import It is forbidden to warn the macro #import. 3.7.4. -Pedantic 3.7.5. -Pedantic-errors3.7.6. -W There are many switches related to warning processing, and then make it again. 3.8. Debugging Options 3.8.1. -g Open the debugging switch and make the compiled target file with debug information. There are still many switches related to debugging processing, and then make up. 3.9. Optimization Switch (Optimization Options) -O1 -O2 -O3 -O0, these switches control optimized strength, and -O3 is the strongest. 3.10. Target Switch (Target Options) 3.10.1. -B Machine In some cases, the target code compiled by the GCC compiler is not running on the machine running this compile action, which is another machine. This compile is called cross-compilation, which is used to run the final target code. Machine is used to indicate the type of target machine. 3.10.2. -V Version The Version parameters are used to represent the version of the number of functions used to tell the compiler to use it. 3.11. CPU-related switch (Machine Dependent Options) More, it is also used when cross-compilation. talk about it later. 3.12. Code Generation Option **************************************************** *********************************************************** ** GCC Use Guide to use syntax: GCC [option | filename] ... G [option | filename] ... The option when Option is used for GCC (will be detailed later), and FileName is a file that wants to process GCC. Description: This COMPILER of C has been integrated with related programs that generate new programs. Generating a new procedure requires four phases: pretreatment, compile, assembly, link, and these two compilers can process the input files different stages. Although the extension of the original program can be used to resolve the language used by the original program code, the different Compiler, its preset handler is different: The GCC presets the file via the pre-processed (extension-name .i) as a C language, and is handled in C in C in C. G defaults to the C language via the pre-processed (extension .i) and processes the program linkage to C connection mode. The extension of the original program code indicates the language used by the written program used, and the corresponding method of processing: .C C original program; pretreatment, compilation, assembly .c C original program; pretreatment, compilation, assembly .cc C original program; pre-processing, compilation, assembly .cxx C original program; pretreatment, compilation, assembly .m Objective-c original program; pretreatment, compilation, assembly .i has been pre-processed C original program; compilation, assembly .ii has passed the C original program that has been pre-processed; compile, compile. S-combined language original program; assembly .s Combined language original program; pretreatment, assembly .h pre-processing file (header file); (not often in the instruction line) Other extensions have been processed by links, usually: .o Object File .a Archive File Unless the compilation process has an error, "link" must be the final stage of a new program. However, you can also stop one of the four phases in four phases of options such as -c, -s or -e. In the coupling phase, all the .o files, libraries, and other files that cannot be identified from the original code (including the Object File that are not extended, as well as the extension .a), including .a .a archive file) Both will be handed over (in the instruction line as the parameter passing to the connection program). Option: Different options must be separated: For example, `-dr 'This option is different from` -d -r'. Most of the larger `-f 'and` -w' options have two forms: -fname and -fno-name (or -wname and -wno-name). The following is only listed in the non-preset form. The following is a summary of all options. Classified in the form. The meaning of the option will also make another section. General (rough, commonly used) option -c -s -e -o file -pipe -v -x loguage Program Language Options - Mismi-Fall-Virtual -fcond-Mismatch -fdollar-in-Identifiers -Fenum-int-equiv -fexternal-templates -fno-asm -fno-builtin -fno-strict-prototype -fsigned-bitfields -fsigned- Char -fthis-is-variable -funsigned-bitfields -funsigned-char -fwritable-strings -traditional -traditional-cpp-trigraphs WARNING Options - FSYNTAX-OnLY -PEDANTIC -PEDANTIC-ERRORS -W -W -WALL-WAGGREGATE-RETURN -WCAST-ALIGN -WCAST-QUAL -WCHAR-SUBScript -wcomment -wconversion -wenum-clamp -werror -wformat -werror -wformat Wid-clash-len -Wimplicit -Winline -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-import -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wstrict-prototypes -Wswitch -Wtemplate- Debugging -wtraditional -wtrigraphs -wuninitialized -wunused -wwrite-strings Error option -a -dletters -fpretend-float -g -glevel -gcoff -gxcoff -gxcoff -gdwarf -gdwarf -Gstabs -gstabs -ggdb -p -pg -save-temps -print-file-name = library -print- libgcc-file-name -print-prog-name = program optimization options -fcaller-saves -fcse-follow-jumps -fcse-skip-blocks -fdelayed-branch -felide-constructors -fexpensive-optimizations -ffast-math - FFLOAT-STORE -FFORCE-AddR -FFORCE-MEM -FINLINE-FUNCTIONS -FKEEP-INLINE-FUNCTIONS -FMEMOIZE-LOOKUPS-FNO-DEFAULT-INLINE-FNO-DEFER-POP-FNO-FUNCTION-Cse -fno-inline -fno- PEEPHOLE -FOMIT-FRAME-POINTER -FRERUN-CSE-AFTER-LOOP -FSCHEDULE-INSS - FSCHEDULE-INS2 -FSTRENGTH-REDUCE-FTHREAD-JUMPS -FUNROLL-All-loops -Funroll-loops -o -o2 Pretreatment Options - OAASSERTION -C -DD -DM -DN -DMACRO [= DEFN] -E-H -IDIRAFTER DIR -INCLUDE FILE-IMCROS file -iprefix file -iwithprefix dir -m -md -mm -mmd -nostdinc -P -Umacro -undef Assembler Options - WA, Option Connection program - LLIBRARY -NOSTARTFILES -NOSTDLIB -STATIC -SHARED -SYMBOLIC -XLINKER OPTION -WL, OPTION -U SYMBOL Directory Options - BPREFIX -IDIR -I- -LDIR Target Options -b Machine -V Version With machine (platform) related options M680x0 options -m68000 -m68020 -m68020-40 -M68030 -MBITFIELD -MC68000 -MC68020 -MFPA -MNOBITFIELD-MRTD -MSHORT -MSOFT-FLOAT VAX OPTIONS -MG-MGNU -Munix SPARC OPTIONS -MEPILOGUE-MFPU -MHARD-FLOAT-MNO-FPU -MNO-EPILOGUE -MSOFT-FLOAT -MSPARCLITE -MV8 -MSUPERSPARC -MCYPRESS CONVEX OPTIONS -MARGCOUNT -MC1 -MC2 -MNOARGCOUNT AMD29K Options -m29000 -m29050 -mbw -mdw -mkernel-registers -mlarge -mnbw -mnodw -msmall -mstack-check -muser-registersM88K Options -m88000 -m88100 -m88110 -mbig-pic -mcheck-zero-division -mhandle- LARGE-SHIFT-MIDENTIFY-REVISION-MNO-CHECK-ZERO-DIVISION-MNO-OCS-DEBUG-INFO -MNO-OCS-FRAME-POSITION -MNO-OPTIMIZE-ARG-area -Mno-Serialize-Volatile -Mno-underscores - MOCS-DEBUG-INFO -MOCS-FRAME-POSITION -MOPTIMIMIZE-ARG-Area-MSerialize-Volatile-MVR4 -MTRAP-LARGE-SHIFT -MUSE-DIV-INSTRUCTION -MVERSION-03.00 -Mwarn- Passed-structs RS6000 OPTIONS -MFP-IN-TOC -MNO-FOP-IN-TOC RT OPTIONS-MCALL-LIB-MUL-MFP-Arg-in-fpregs -mfp-arg-in-gregs-MFULL-FP-BLOCKS-MHC-STRUCT-RETURN -LIN-LINE-MUL-MMINIMUM-FP-block-mminhc -Struct-Return MIPS OPTIONS -MCPU = CPU TYPE -MIPS2 -MIPS3 -MINT64 -MLONG64 -MLONGLONG128-MMIPS-AS -MGAS -MRNAMES -MNO-RNAMES -MGPOPT -MNO-GPOPT -MSTATS -MNO-Stats -mmemcpy -Mno-MNO-MNO- MIPS-TFILE-MMIPS-TFILE-MSOFT-FLOAT-MHARD-FLOAT-MABICALLS -MNO-ABICALLS-MHALF-PIC -MNO-HALF-PIC -G Num -NOCPP I386 OPTIONS -M486 -MNO-486 -MSOFT-FLOAT -MNO-FP-RET-IN-387 HPPA OPTIONS -MPA-RISC-1-0 -MPA-RISC-1-1 -Mkernel-mshared-Libs -Mno-Shared-Libs -mlong-Calls -Mdisable-fpregs -Mdisable-Indexing -Mtrailing-Colon I960 OPTIONS-MCPU-TYPE-MNUMERICS -MSOFT-FLOAT-MLEAF-PROCEDURES -MNO-LEAF-PROCEDURES -MTAIL-CALL-MNO-TAIL-CALL -MCOMPLEX-AddR-Mno-COMPLEX-AddR -MCODE-Align-Mno-Code -Align -Mic-compat -Mic2.0-compat -mic3.0-compat -masm-compat -mintel-asm-mstrict-align-mno-strict-align-align-mald-aligndec alpha options -mfp -regs-malo-fp-regs-malo-soft-float-msoft-float System v options -g -qy -qn-yp, paths -ym, dir Code Generation Options -fcall-Saved-Reg-Fcall-use-reg -ffixed-regall-limited-size-directive -fnonnull-objects -fno-common -fno-ident -fno-gnu-linker -fpcc-struct-return-FPCC-STRUCT-RETURN - FPIC-FPIC -FREG-STRUCT-RETURNO -FSHARED-DATA-FSHORT-ENUMS -FSHORT-DOUBLE -FVOLATILE -FVOLATILE-GLOBAL -FVERBOSE-ASM PRAGMAS Two `#pragma 'directives are supported for GNU C , to permit using the same header file for two purposes: as a definition of interfaces to a given object class, and as the full definition of the contents of that object class. #pragma interface (C only.) Use this directive in header files that define object classes, to save space in most of the object files that use those classes. Nor- mally, local copies of (backup copies certain information of inline member functions, debugging infor- mation, and the internal tables that implement vir- tual functions) must be kept in each object file that includes class definitions. You can use this pragma to avoid such duplication. When a header file containing `#pragma interface 'is included in a compilation, this auxiliary information will not be generated (unless the main input source file it- self uses `#pragma implementation '). Instead, the object files will contain references to be resolved at link time. # pragma implementation #pragma implementation "objects.h" (C only.) Use this pragma in a main input file, when you want full output from included header files to be generated (and made globally visible). The included header file, in turn, should Use `#pragma interface '. Backup Copies of Inline MEM- BER FUNCTIONS, Debugging Information, And The IN- TERNAL TABLES USED TO IMPLEMENT VIRTUAL FUNCTION SILES. If you use `#pragma implementation 'with no argu- ment, it applies to an include file with the same basename as your source file; for example, in` allclass.cc', `#pragma implementation 'by itself is equivalent to` #pragma implementation "allclass.h" '. Use the string argument if you want a single implementation file to include code from multiple header files.There is no way to split up the contents of a single header file into multiple implementation files. Document Description File.c C Source File File.h C Header (Preprocessor) File File.i Pretreatable C Source File File.c C Source File File.cc C Source File File.cxx C Source File File.m Objective -C source file file.s assembly language file file.o object file a.out link edited output TMPDIR / cc * temporary files LIBDIR / cpp preprocessor LIBDIR / cc1 compiler for C LIBDIR / cc1plus compiler for C LIBDIR / collect linker front end needed ON Some Machines Libdir / Libgcc.a GCC Subroutine Library /Lib/crt[01N].o Start-Up Routine Libdir / CCRT0 Additional Start-Up Routine For C / Lib/Libc.a Standard C Library, see Man Page Intro (3 ) / usr / include standard directory for #include files LIBDIR / include standard gcc directory for #include files LIBDIR / g - include additional g directory for #include LIBDIR is usually / usr / local / lib / machine / version. TMPDIR COMES from the Environment Variable Tmpdir (Default / USR / TMP if Available, ELSE / TMP. ******************************************************** -o file Specify the output file name, this option is not necessary when compiling as the target code. If File is not specified, the default file name is A.out. -C Compile not link -Dfoo = bar Define the pre-processed macro foo in the command line, its value is BAR -Idirname Add DIRNAME to the list of search directories in the header file -LDIRNAME Add DIRNAME to the list of search directories in the library file, default GCC link sharing library -static Link static library, execute static link -LFOO Linking a libfoo function library -g In executable program contains standard debugging information -ggdb In the executable contains only GNU Debugger to make two more information -O Optimize the compiled code -On The level of specified code optimization is n, o <= n <= 3 -ansi Support ANSI / ISO C standard syntax, cancel the GNU's syntax extension, conflict with this standard (But this option does not guarantee generation of ANSI-compatible code) -pedantic Allow all warnings listed by ANSI / ISO C standard -pedantic -rrors Allow all errors listed by ANSI / ISO C standard -traditional Support Kernighan & Ritchie C syntax (if you define functions with old grammar); if you don't know the meaning of this option, it doesn't matter. -w Close all warnings, do not use this item .Wall Allow all useful warnings that GCC can provide, or use -w (warning) to mark the specified warning -wrror Convert all warnings to errors to stop compiling the compilation during warning -Mm Output a MAKE-compatible list -V Show commands used in each step of the compilation process