Command |
Description |
-L Library -LLibrary |
Search for libraries named Library when making links. Example: $ gcc test.c-lm-o test |
-I.dir |
Add dir to the path list of the search header file. Example: $ gcc test.c-i. /inc-o Test |
-Ldir |
Add dir to the path list of the search library file. Example: $ gcc-i/home/foo-l/home/foo-ltest test.c-o test |
-DName |
A macro named name is predefined, with a value of 1. Example: $ gcc-dtest_config test.c-o test |
-Dname=definition |
A macro named namewith a value of definition is predefined. |
-ggdb -ggdb Level |
Generates debug information for the debugger gdb. level can be in 2, and the default value is. |
-G - G level |
Generates debug information for the operating system local format. -G and-ggdb are not the same, and-G generates information outside of GDB. level value as above. |
-S |
Removes symbol tables and relocation information from the executable file. Used to reduce the size of the executable file. |
-M |
Tells the preprocessor to output a rule that is appropriate for make to describe the dependencies of each target file. For each source file, the preprocessor outputs a make rule where the target entry (target) of the source file corresponds to the destination file name, and the dependency (dependency) is the ' #include引用的所有文件 in the source file. The generated rule can be a single row, but if it is too long, use '/'-line Fu Yi into multiple lines. The rules are displayed in standard output and do not produce pre-processed C programs. |
-C |
Tells the preprocessor not to discard comments. Use with the '-e ' option. |
-P |
Tell the preprocessor not to produce a ' #line ' command. Use with the '-e ' option. |
-static |
Block connections to shared libraries on systems that support dynamic linking. This option is not valid on other systems. |
-nostdlib |
No system standard boot files and standard library files are connected, only the specified files are passed to the connector. |
Warnings |
|
-wall |
Some useful warning options are turned on, and it is recommended to compile with this option. |
-W -wextra |
Print some additional warning messages. |
-W |
Suppresses the display of all warning messages. |
-wshadow |
A warning is given when a local variable obscures another local variable, or a global variable. Useful option, it is recommended to open. -wall does not open this entry. |
-wpointer-arith |
A warning is given when arithmetic operations are performed on a function pointer or a pointer of type void *. is also very useful. -wall does not open this entry. |
-wcast-qual |
A warning is given when a cast loses a type modifier. -wall does not open this entry. |
-waggregate-return |
If a function that returns a struct or union is defined or called, the compiler warns. |
-winline |
Whether the declaration is inline or the-finline-functions option is specified, the compiler will issue a warning if a function cannot be inline. This is a useful option if your code contains many inline functions. |
-werror |
Treat the warning as an error. Discard the compilation if any warnings occur. |
-wunreachable-code |
If the compiler detects code that is never executed, a warning is given. is also a more useful option. |
-wcast-align |
The compiler warns you when a pointer-type cast causes the desired address alignment for the target to increase. |
-wundef |
A warning is given when a symbol that is not defined appears in the #if. |
-wredundant-decls |
If a definition is declared multiple times within the same visible domain, the compiler warns you, even if the duplicate declarations are valid and are not different. |
optimization |
|
-o0 |
Prevents the compiler from being optimized. Default for this item. |
-O -o1 |
Try to optimize compilation time and executable file size. |
-o2 |
More optimizations will try almost all of the optimizations, but not the "space-for-time" optimization method. |
-o3 |
On the basis of-O2 to open some of the optimization options:-finline-functions,-funswitch-loops and-fgcse-after-reload. |
-os |
Optimizes the size of the build file. It will open all the options-o2 open, except those that increase the file size. |
-finline-functions |
Put all the simple functions inline into the caller. The compiler will explore what functions are simple enough to be worth doing inline. |
-fstrict-aliasing |
Apply the strongest alias rule (aliasing rules). |
| Standard
|
-ansi |
Supports C programs that conform to ANSI standards. This will turn off some of the incompatible ANSI C features in GNU C. |
-std=c89 -iso9899:1990 |
Indicates that the program is compiled using standard ISO C90 as a standard. |
-std=c99 -std=iso9899:1999 |
Indicates that the program is compiled using standard ISO C99 as a standard. |
-std=c++98 |
Indicates that the program is compiled using standard c++98 as a standard. |
-std=gnu9x -std=gnu99 |
Use ISO C99 plus some of the GNU extensions. |
-fno-asm |
ASM, inline, or typeof are not treated as keywords, so these words can be used as identifiers. With __asm__, __inline__ and __typeof__ can replace them. The '-ansi ' implicitly declares '-fno-asm '. |
-fgnu89-inline |
Tells the compiler to use the traditional GNU syntax when it sees the inline function in C99 mode. |
C Options |
|
-fsigned-char -funsigned-char |
Define char as a/unsigned type, as signed char/unsigned Char. |
-traditional |
Try to support some aspects of the traditional C compiler. See the GNU C Manual. |
-fno-builtin -fno-builtin-function |
Functions that do not have __builtin_ prefixes are not accepted as built-in functions. |
-trigraphs |
A triple character (trigraphs) that supports ANSI C. The '-ansi ' option implicitly declares this option. |
-fsigned-bitfields -funsigned-bitfields |
If the ' signed ' or ' unsigned ' modifier is not explicitly declared, these options are used to define the signed bit field or the unsigned bit field. By default, bit fields are signed because they inherit the base integer type, such as int, which is a signed number. |
-wstrict-prototypes |
If the declaration or definition of a function does not indicate a parameter type, the compiler warns you. A useful warning. |
-wmissing-prototypes |
If a global function is defined without a pre-declaration, the compiler warns. This warning is generated even if the function definition itself provides a prototype of the function. The purpose of this option is to check for global functions that are not declared in the header file. |
-wnested-externs |
If an extern declaration appears inside the function, the compiler issues a warning. |
C + + options |
|
-ffor-scope |
Execute the program from the beginning, and also allow redirection. |
-fno-rtti |
Turn off support for dynamic_cast and typeID. If you don't need these features, turning it off will save you some space. |
-wctor-dtor-privacy |
Give a warning when a class is not available. Because constructors and destructors are treated as private. |
-wnon-virtual-dtor |
A warning is issued when a class has polymorphism without a virtual destructor. -wall will open this option. |
-wreorder |
If the initialization order of member variables in the code is inconsistent with the order in which they were actually executed, a warning is given. |
-wno-deprecated |
Do not give a warning when using outdated features. |
-woverloaded-virtual |
If the declaration of the function hides the virtual function of the base class, a warning is given. |
Machine
Dependent Options (Intel) |
|
-mtune=Cpu-type |
Generates code for the specified type of CPU. Cpu-type can be: I386,i486,i586,pentium,i686,pentium4 and so on. |
-msse -msse2 -mmmx -mno-sse -mno-sse2 -mno-mmx |
Use or do not use the MMX,SSE,SSE2 directive. |
-m32 -m64 |
Generate code on 32-bit/64-bit machines. |
-mpush-args -mno-push-args |
(not) Use the push instruction to store parameters. The default is to use. |
-mregparm=Num |
Controls the number of registers that are used when passing integer parameters. |