UNIX System Development -gcc arguments detailed http://www.chinaunix.net Author: sdccf Posted: 2004-01-02 21:37:44
[Version] -0.13 [Declaration] This document is my note about gcc parameters. I miss the DOS era. I use a small book, record all DOS command parameters. Haha, the following things may not be very comprehensive, I Refer to lots of books, and GCC help. If the reason is that I haven't seen this parameter yet, the reason is that I may not use it, I will slowly make up. Haha If you want to turn in this article, please keep the comprehensiveness of my email (pianopan@beeship.com) and article. [Introduction] GCC and G is the GNU's C & C compiler GCC / G when performing compilation work, 4 steps 1. Pretreatment, generate .i file [Preprocessor CPP] 2. Pretreatment files do not convert the pre-processed files into assembly language, generate files. S [Compiler EGCS] 3. Subcombinations become targets Code (machine code) generated. Own file [assembler as] 4. Connect the target code, generate the executable [LED] [Parameter Details] -X Language FileName Set the language used by the file, make the retrore name invalid For future multiple valid. That is, based on the suffix name of the convention C language is .c, and C suffix name is .c or .cpp, if you are very personal, decide that your C code file is the suffix name. Pig Haha, then you have to use this parameter, this parameter works on his file name, unless the next parameter is used. The parameters you can use have these `c ',` Objective-c', `c-header ',` C ', `cpp-output ',` assembler', and `assembler-with-cpp '. See English should be understood. Example usage: gcc-x c hello.pig -x none filename turned off the previous option, that is, let GCC automatically identify file type example usage: gcc-x c hello.pig -x none hello2.c - c only activate pretreatment, compile, and compile, that is, he only makes the program into an OBJ file example usage: gcc -c hello.c He will generate .o Obj file -s only activates pre-processing and compile, means The file is compiled into assembly code. Example GCC -S Hello.c He will generate .S assembly code, you can use the text editor to view -e only activate pre-deputation, this does not generate files, you need to redirect it to an output file. Example usage : Gcc -e hello.c> Pianoapan.txt gcc -e hello.c | more slowly, a Hello Word also develops a target name with code -o processing to 800 rows, is default, GCC compiled The file is a.out, it is difficult to listen, if you have the same feeling, change it, haha example gcc -o hello.exe hello.c (Oh, Windows habit) gcc -o hello.asm -s Hello .c -pipe uses the pipeline instead of the temporary file, when using a non-GNU assembly tool, some questions may be gcc -pipe -o hello.exe hello.c -ansi to close the characteristics of incompatible with ANSI C in GNU C, activation ANSI C's proprietary feature (including some ASM inline typeof keywords, and UNIX, VAX and other pre-processing macros, -fno-asm This option implements a part of the function of the ANSI option, which is forbidden to use ASM, Inline and TypeOf as a key word.
-fno-strict-prototype works only to G , using this option, G will be a function that does not have parameters, it is considered that there is no explicit to the number and type description of the parameters, not without parameters. And GCC does not With this parameter, you will have a function without parameters. It is considered that the city has no explicitly instructions. The second and third parameter types do not match, the value of the expression will be the four parameters of the VOID type -funsigned-car -fno-signed-char-fsigned-char -fno-unsigned-char, which is set to the char type, decided Set the char type to unsigned char (the first two parameters) or Signed char (the latter two parameters) -include file contains a code, simply, when you use a file, you can need another file. With it, the function is equivalent to using a #include
-Md and -m are the same, but the output will be the same as the file imported to .d and -mm, but the output will be imported into .d -Wa, Option This option passes the Option to the assembler; if there is Option Command, divide Option into multiple options, then pass to the assembler -wl.option This option passes the Option to the connection program; if there is a comma in the option, the Option is divided into multiple options and then passed to the program. LLIBRAR is used to use the library example GCC -LCURS HELLO.C to use the NCURSES library compiler - LDIR to search the path. For example, your own library, you can use it to create a directory, otherwise the compiler will only look at the directory of the standard library. This DIR is the name of the directory. The 4 levels of the optimization options for the -O0 -O1 -O2 -O3 compiler, -O0 indicate that the -O0 is not optimized, -O1 is the default value, the -O3 optimization level is only the compiler, when compiling, generate debugging information . -gstabs This option claims to debug information in the Stabs format, but does not include GDB debugging information. You can use debugging information. -Static This option will ban the use of dynamic libraries, so compiled things, it is generally large, you don't need any dynamic connection library, you can run. -Share This option will try to use dynamic libraries Therefore, the generated file is relatively small, but the system needs the system by dynamic library. -Traditional tries to support the compiler to support traditional C language features [Reference information] -Linux / UNIX Advanced Programming Zhongke Hongqi Software Technology Co., Ltd. Published. Tsinghua University Press Publishing -Gcc man Page [Changelog] -2002-08-10 Ver 0.1 Releases the original document-2002-08-11 Ver 0.11 Modified Document format-2002-08-12 Ver 0.12 Add to static library, dynamic library parameters -2002 -08-16 Ver 0.16 Increased 4 stages of GCC compilation to run GCC / EGCS *********** Run GCC / EGCS **************** ******* GCC is a GNU's C and C compiler. In fact, GCC can compile three languages: C, C and Object C (an object-oriented extension of C language). The C and C source programs can be compiled and connected with the GCC command. If you have two or a few C source files, you can easily compile, connect, and generate executables using GCC. For example, suppose you have two source files main.c and factorial.c two source files, and now you have to build a program that generates a calculating order.
Code: ----------------------- List Factorial.c --------------------- - int factorial (int N) {IF (n <= 1) Return 1; Else Return Factorial (N - 1) * n;} ------------------- ---- List main.c ----------------------- #include