GCC Chinese Manual (on) -zz

xiaoxiao2021-03-06  16

Name

GCC, G - GNU

Engineering

C

with

C

translater

(EGCS-1.1.2)

Overview (Synopsis)

GCC [option | filename] ... G [option | filename] ...

WARNING

This handbook content is taken from

GNU C

Full documentation for the compiler

,

Only in the meaning of explanation options

.

This book page is no longer updated unless someone voluntarily maintained. If there is any contradiction between man page and software, check the Info file, the Info file is an authoritative document.

If we find that the content of this handbook causes obvious chaos and complaints due to outdated, we stop posting it. It is impossible to have other options, and the information updated in the INFO file is updated at the same time, because other maintenance GNU CC does not leave We do this. The GNU project believes that the Man's manual is an outdated product, and the time should be used in other places.

If you need full and up-to-date documentation, review info files `GCC 'or use and porting gnu cc (for version 2.0) (for Version 2.0) manual. Both are from Texinfo original file gcc.texinfo.

Description (Description)

C

with

C

The compiler is integrated

.

They all use one or more of the four steps to input files.

:

Pretreatment

PreProcessing,

Compile

(Compilation)

compilation

(askSSEMBLY)

Connection

Linking.

Source file after the hypermination name logo source file language

,

But for the compiler

,

The suffix name controls the default setting

:

GCC

Think pre-processed files

(.i)

Yes

C

file

,

And set

C

Form connection

.

G

Think pre-processed files

(.i)

Yes

C

file

,

And set

C

Form connection

.

Source file suffix name indicates the language type and the later operation:

.C C source program; pretreatment, compilation, compilation

.C C source program; pretreatment, compilation, compilation

.CC C source program; pretreatment, compilation, compilation

.cxx C source program; pretreatment, compilation, compilation

.m Objective-C source program; pretreatment, compilation, compilation

.i pre-treated C file; compile, compilation

C files after pre-treatment; compile, compilation

.S assembly language source program; compilation

.S assembly language source program; pretreatment, compilation

.h preparation instrument file; usually do not appear on the command line

The files of other hyperfoxes are passed to the connector

Linker.

Usually included

:

.o target file (Object file)

.a archive library file (Archive file)

Unless the -c, -s, or -e option (or compiling errors blocked the complete process), the connection is always the final step. In the connection phase, all the .o files, -l library corresponding to the source program Files, unrecognized file names (including specified .o target files and .a library files) are passed to the connector in the order in the command line.

Options (options)

Options must be given separately

: `-dr '

Completely different from

`-d -r '.

Most `-f 'and` -w' options have two opposite formats: -fname and -fno-name (or -wname, and -wno-name). Only in the format that is not the default option.

Below is a summary of all options, groups, explains in the later chapter.

Overall Option

-c -s -e -o file -pipe -v -x loguage

Language Option

-ansi -fall-virtual -fcond-mismatch -fdollars-in-identifiers -fenum-int-equiv -fexternal-templates -fno-asm -fno-builtin -fhosted -fno-hosted -ffreestanding -fno-freestanding -fno-strict -Prototype -fsigned-bitfields -fsigned-char -fthis-is-variable -funsigned-bitfields -funsigned-char -fwritable-strings -traditional -traditional-cpp -trigraphs warning option (WARNING OPTION)

-fsyntax-only -pedantic -pedantic-erroate -w -w -wall -waggregate-return -wcast-align -wcast-qal -wchar-subscript -wcomment -wconversion -wenum-clamp -wrror -wformat -wid-coplash-len -Wimplicit -Wimplicit-int -Wimplicit-function-declaration -Winline -Wlong-long -Wmain -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-import -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -wstrict-prototypes -wswitch -wtemplate-debugging -wuninitial -wtrigraphs -wuninitialized -wunused -wwrite-strings

Debugging Option

-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 option (Optimization Option)

-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-pipe -freun-cse-frame-pipe -fschedule -ins - -fschedule-insns2 -fstrength-redument -fthread-jumps -funroll-all-loops -funroll-loops -o -o2 -o3

Preprocessor Option

-Aassertion -c -dd -dm -dn -dmacro [= defn] -e -idirafter dir -include file -imacros file -iprefix file -iwithprefix dir -m -md -mm -mmd -nostdinc -p -umacro - Undef assembler options (Assembler Option)

-WA, Option

Connector Option (Linker Option)

-LLIBRARY -NOSTARTFILES -NOSTDLIB -STATIC -SHARED -SYMBOLIC -XLINKER OPTION -WL, OPTION -U SYMBOL

Directory Option (Directory Option)

-BPREFIX -IDIR -I---LDir

Target Options (Target Option)

-B Machine -V Version

Configuration Related Option (Configuration Dependent Option)

M680x0 option

-M68000 -M68020 -M68020-40 -M68030 -M68040 -M68881 -MBITFIELD -MC68000 -MC68020 -MFPA -MNOBITFIELD-MRTD -MSHORT -MSOFT-FLOAT

VAX option-mgnu -munix

SPARC option -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-Registers

M88K Options - MNO-LARGE-SHIFT - MNO-OCS-OCS-DEBUG-INFO-MNO-OCS-FRAME -POSition -Mno-Optimize-arg-alla-mno-serialize-Volatile -Mno-undrees -mocs-debug-info -mocs-frame-position -moptimize-arg-alla-mSerialize-Volatile -Mshort-data-num -MSVR3 -msvr4 -mtrap-large-shift -muse-div-instruction -mversion-03.00 -mwarn-passed-structs

RS6000 Options - Mfp-in-Toc-Mno-Fop-in-TOC

RT option-mcall-lib-mul-mfp-arg-in-fpregs -mfp-arg-in-gregs -mFull-fp-block-MHC-STRUCT-RETURN -MIN-line-mul-mminimum-fp-block-mminohc -Struct-Return

MIPS Options - MCPU = CPU TYPE -MIPS2 -MIPS3-MINT64 -MLONG64 -MMIPS-AS -MGAS -MRNAMES -MNO-RNAMES -MGPOPT -MNO-GPOPT -MSTATS -MNO-STATS -MMEMCPY -MNO-MNO-STATS -MMEMCPY-MNO-MEMCPY -MNO-MIPS- TFILE-MMIPS-TFILE-MSOFT-FLOAT -MHARD-FLOAT-MABICALLS -MNO-ABICALLS -MHALF-PIC -MNO-HALF-PIC -G NUM -NOCPPI386 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-MnUMTAIL-MNODE-TAIL-CALL-MNODE - MNO-CALL-MNODE - MNO-CALL-MNO-MNO - MNO-code -Align -Mic-compat -Mic2.0-compat -Mic3.0-compat -masm-compat -mintel-asm-mstrict-align-mno-strict-align -mold-align-mald-align

DEC Alpha option - mfp-regs-malo-fp-regs-maloat-float-msoft-float

SYSTEM V option -g -qy -qn -yp, paths -ym, dir

Code Generation Option (Code Generation Option)

-fcall-saved-reg-call-buy-reg -ffixed-reg-definhibit-size-directive -fnonnull-objects -fno-common -fno-ident -fno-gnu-linker -fpcc-struct-return-fpic -fpic -freg-struct-return -fshared-data -fshort-enums -fshort-double -fvolatile -fvolatile-global -fverbose-asm

Overall Option

-x Language

Clearly point out the language of the backup file

LANGUAGE

Instead of obtaining the default selection from the file name suffix

).

This option is applied to all of the input files later

,

Until in the next one

`-x '

Option

Language

Optional value

`c ',` Objective-c', `c-header ',` C ', `cpp-output ',` Assembler',

with

`assembler-with-cpp '.

-x none

Close any clear explanation of language species

,

So according to the files behind the file name suffix

(

As is like never used

`-x '

Option

).

If you only operate some of the four phases (preprocessing, compile, assembly, connection), you can use the `-x 'option (or file name suffix) to tell where to start, using` -c', `-s', Or `-e 'option tells the GCC where to end. Note that some options are combined (for example,` -x cpp-outprut -e') makes GCC do nothing.

-C

Compile or assemble source files

,

But do not connect

.

The compiler outputs the target file corresponding to the source file

.

By default, GCC generates a target file name by replacing the source file name suffix`c ', `.i',` .s', and so on. You can use the -o option to select another name.

The GCC ignores the -c option, any unrecognized input file (they don't need to be compiled or assembled).

-S

Stop after compiling

,

Not compile

.

For each input non-assembly language file

,

Output file is a compilation language file

.

By default, GCC generates a target file name by replacing the source file name suffix`c ', `.i', and so on. You can use the -o option to select another name.

GCC ignores any input files that do not need to be compiled.

-E

Stop after pre-treatment

,

Not compile

.

Pretreatment code sent to standard output

.

GCC ignores any input files that do not require pre-processing.

-o file

Specify output file

File.

This option is not

GCC

What output is generated?

,

Whether it is an executable

,

Target file

,

Compilation files are still pretreated

C

Code

.

Since only one output file can only be specified, it is not meaningless when compiling multiple input files, unless an executable is output unless an executable file is output.

If you do not use the `-o 'option, the default output result is: the executable file is` a.out', `source.suffix 'target file is` source.o', assembled file is `Source.s', and The pre-processed C source code is sent to the standard output.

-V

(

In standard error

)

Show commands in executing compilation phase

.

Conframe driver at the same time

,

Prepaid

,

The version number of the compiler

.

-pipe

Communication is used in different stages of the compilation process rather than temporary files

.

This option is unable to work in some systems

,

Because those system assemblers cannot read data from pipelines

GNU

Assembler does not have this problem

.

Language Options

The following options control the compiler to accept

C "

dialect

":

-ansi

Support

ANSI

standard

C

program

.

This will close some of the GNU C, such as ASM, Inline, and TypeOf keywords, as well as a predefined macro, such as UNIX and VAX indicating the current system type. At the same time, open unopened and very small use. ANSI TRIGRAPH features, and disabled `$ 'part of the identifier.

Although the `-ansi 'option is used, the following optional keywords, __asm__, __extension____inline__ and __typeof__ are still valid. Of course, you will not use them in the ANSI C program, but you can put them on the head In the file, because compiling programs containing these header files, you may specify the `-ansi 'option. Other predefined macros, such as __unix__ and __vax__, no matter whether there is a` -ansi' option, always valid.

Using the `-ansi 'option does not automatically reject the non-ANSI program unless added to the` -pedant' option as a supplement to the `-ansi 'option.

When using the `-ansi 'option, the preprocessor will preview a __strict_ansi__ macro. Some headers pay attention to this macro to avoid declaring certain functions, or avoid defining certain macros, these functions and macro are not called by ANSI standards This will not interfere with the programs that use these names elsewhere.

-FNO-ASM

Not to

ASM, Inline

or

Typeof

As a keyword

,

So these words can be used to make an identifier

.

use

__ASM__, __inline__

with

__typeof__

Ability to replace them

. `-ansi '

Implicit declaration

`-fno-asm '.

-fno-builtin

Do not accept built-in functions that are not two underscores

Built-in function.

Currently affected functions

_exit, Abort, ABS, Alloca, Cos, Exit, Fabs, Labs, Memcmp, Memcpy, Sin, SQRT, STRCMP, STRCPY,

with

Strlen.

`-ansi 'options prevent alloca and _exit from built-in functions.

-fhosted

Compile according to host environment

;

He implies the statement

`-fbuiltin '

Option

,

And the warning is incorrect

main

Function declaration

.

-freeestanding

Compile by independent environment

;

He implies the statement

`-fno-builtin '

Option

,

But also

main

There is no special request

.

(Translation: Host Environment, all standard libraries are available, the main function returns an int value, typical examples are almost all programs other than the kernel. The corresponding independent environment does not exist in standard libraries, the program entry is also It is not necessarily main, the most obvious example is the operating system core. Details reference information recent in the GCC website)

-fno-strict-prototype

Declaration for function without parameters

,

E.g

`Int foo (); ',

press

C

Style treatment

---

That is, no number of parameters or types

(

Only

C ).

Under normal circumstances

,

Such a function

foo

in

C

Meaning the parameters empty

.

-Trigraphs

stand by

ANSI C Trigraphs. `-Ansi '

Option implies declaration

`-trigraphs'.

-traditional

Try to support the tradition

C

Some aspects of the compiler

.

See

GNU C

manual

,

We have removed the details from here

,

This is when the content is outdated

,

People will not blame us

.

In addition to one thing: For C programs (not c), `-traditional 'options bring an additional effect, allowing this assignment. His effect is the same as the` -fthis-is-variable' option.

-Traditional-CPP

Try to support the tradition

C

Some aspects of the preparation

.

In particular, the content of the pre-processor is mentioned above.

,

But not included

`-traditional '

Other effects of options

.

-fdollars-in-identifiers

Allowed in the identifier

(Identifier)

In use

`$ '

character

(

Only

C ).

You can specify

`-fno-dollars-in-identifiers'

Options showed disabled use

`$ '

symbol

(GNU C

By certain target system

`$ '

symbol

,

But not all systems

.)

-fenum-int-equiv

allow

int

Type to enumeration type

(ENUMERATION)

Implicit conversion

(

Be limited to

C ).

Under normal circumstances

GNU C

Allowance

ENUM

Until

int

Conversion

,

It is not possible.

.

-fexternal-templates

Declaration for template

(Template Declaration)

Produce smaller code

(

Be limited to

C ),

The method is for each template function

(Template function),

Generate a copy only in their place

.

I want to successfully use this option

,

You must be in all files that use templates

,

mark

`#pragma impLementation '

definition

)

or

`#pragma interface '(

statement

).

When the program is compiled with `-fexternal-templates', all the template instances are all external types. You must make the required instance appear in the implementation file. You can implement this with TypeDef, and he references each instance of the required Comparison, if you use the default options `-fno-external-templates', all template instances are clearly set to built-in.-Fall-Virtual

All possible member functions default to virtual functions

.

All member functions

(

In addition to the constructor and

New

or

Delete

Member operator

)

Deverse virtual functions

.

This does not indicate that each call member function will pass through the internal virtual function table. In some cases, the compiler can determine that you can call a virtual function directly; then call it directly.

-fcond-mismatch

Allow the type of the second and third parameters of the conditional expression without match

.

This expression of this expression is

Void.

-fthis-is-variable

Allow

THIS

Value

(

Only

C ).

Merged user-defined free storage management mechanisms

C

Rear

,

Assignable

`THIS '

Appetite

.

therefore

,

by default

,

Internal pair of class member functions

THIS

Assignment is invalid

.

However, in order to backward compatibility

,

You can pass

`-fthis-is-variable '

Option makes this operation valid

.

-funsigned-char

Put

charr

Defined as unsigned type

,

as

Unsigned char.

Various machines have their own default char types. It may be unsigned char or Signed Char.

Ideally, a portable program always uses signed char or unsigned char. But many programs have been written as only simple char, and look forward to this is the number of symbols (or no sign) The specific situation depends on the target machine of the program. This option, and its antisense option, so that the program works on the corresponding default value.

Char types should always be explicitly defined as signed char or unsigned char, even if it is exactly the same.

-fsigned-char

Put

charr

Defined as a symbol type

,

as

Signed char.

This option is equivalent to `-fno-unsigned-char ', he is the opposite option of The Negative Form of` -funsigned-char'. Similarly, `-fno-signed-char 'is equivalent to` -funsigned-char'.

-fsigned-bitfields

-funsigned-bitfields

-fno-signed-bitfields

-fno-unsigned-bitfields

If there is no clear statement

`signed '

or

`unsigned '

Modifier

,

These options are used to define a symbolic domain

(Bitfield)

Or unsigned bit

.

Default

,

The bit field is symbolic

,

Because of their inherited basic integer type

,

Such as

Int,

Is the number of symbols

.

However, if the `-traditional 'option is specified, the bit field is always unsigned.

-fwritable-strings

Store string constants to optional data segments

,

And don't do special treatments

.

This is to be compatible with some old procedures

,

They assume that string constants can be writable

. `-traditional '

Option also has the same effect

.

Tampering string constant is a very bad idea; `` constant '' should be constant.

Preprocessor Option

The following options are for

C

Prepaid

,

Preprocessors used before formal compilation

,

Correct

C

Source file for some processing

.

If you specify the `-e 'option, the GCC is only preprocessing. Some options must be made together with the` -e' option because their output results cannot be used to compile.-Include file

Before processing the regular input file

,

First process file

File,

the result is

,

file

File

Content first get compiled

.

Command line

`-D '

with

`-U '

Option forever

`-include file '

Previous process

,

Whether they are in the order in the command line?

.

however

`-include '

with

`-imacros'

Options handles sequentially

.

-imacros file

Before processing the regular input file

,

First process file

File,

But ignore the output result

.

Due to the discardment

File

Output content

, `-imacros file '

The only effect of the option is to make the file

File

Macro definition

,

Can be used for other input files

.

Handle

`-imacrosfile '

Option before

,

Preparation rulers first proceed

`-D '

with

`-U '

Option

,

Don't care about their order on the command line

.

however

`-include '

with

`-imacros'

Options handles sequentially

.

-idirafter Dir

Put the catalog

DIR

Add to the second included path

.

If a header is included in the main included path

(

use

`-I '

Added path

)

Not found

,

Preprocessor search the second included path

.

-IPRefix Prefix

Specify

Prefix

Follow-up

`-iwithprefix '

Option prefix

.

-iwithPRefix Dir

Add the directory to the second included path

.

Directory name

Prefix

with

DIR

Incorporate

,

Here

Prefix

Previously

`-iprefix '

Option specified

.

-nostdinc

Don't look for headers in the standard system directory

.

Search only

`-I '

Option specified directory

(

And current catalog

,

If appropriate

).

In combination with the `-nostdinc 'and` -i-' option, you can limit the contents of the included file to the explicit specified directory.

-nostdinc

a

C

Find header files in the special standard directory

,

But still search other standard catalogs

(

Be established

`libg '

Use this option when

.)

-undef

Don't predefine any non-standard macros

(

Includes system structure logo

).

-E

Run only

C

Prepaid

.

Prerequisites all specified

C

Source File

,

The result is sent to standard output or designated output files

.

-C

Tell the pre-processor not to discard the comment

.

Cooperation

`-E '

Options

.

-P

Tell the pre-processor not to produce

`#Line '

command

.

Cooperation

`-E '

Options

.

-M [-mg]

Tell the pre-processor output a suitable

Make

the rule of

,

Dependency relationship used to describe each target file

.

For each source file

,

Preprocessor outputs one

Make

rule

,

Target item for this rule

(Target)

Is the target file name corresponding to the source file

,

Dependency

(dependence)

Source file

`#include

All files referenced

.

The rules that are generated can be a single line

,

But if it is too long

,

then apply

`/ '-

Renewal is multi-line

.

Rule is displayed in standard output

,

Do not produce pretreated

C

program

.

`-M 'implies the` -e' option.

`-Mg 'requires the missing header file to be treated, and assumes that they and source files are in the same directory. Must be used with` -m' options.-Mm [-mg]

with

`-M '

Options Similar

,

However, the output is only related to user header files.

,

Like this

`#include file" '.

Ignore the system header file such as

`#include '.

-Md

with

`-M '

Options Similar

,

But put the dependency information output in the file

,

The file name is at the end of the output file name

`.o '

Replace

`.d '

produce

.

Continue the designated compilation

--- `-md '

Not like

`-M '

That block normal compilation tasks

.

Mach Utility Tools `MD 'Ability to merge the` .d' file, generate a single dependency file that applies to `make 'commands.

-Mmd

with

`-Md '

Options Similar

,

However, the output is only related to user header files.

,

Ignore the system header file

.

-H

In addition to other ordinary operations

, GCC

Show referenced header names

.

-Aquestion (Answer)

If the pre-processor does condition test

,

Such as

`#if #question (Answer) ',

This option can be asserted

(Ask) Question

The answer is

Answer. -a- '

Turn off standard assertions generally used to describe target machines

.

-Dmacro

Define macro

Macro,

The content of the macro is defined as a string

`1 '.

-Dmacro = DEFN

Define macro

Macro

Content

DEFN.

Command line

`-D '

Option

`-U '

Option before processing

.

-Umacro

Cancel the macro

Macro. `-u '

Options in all

`-D '

After the option

,

But take priority

`-include '

or

`-imacros'

Option

.

-dm

Tell the pre-processor output a valid macro definition list

(

Macro definition still is still effective at the end of the pre-processing

).

This option needs to be combined

`-E '

Options

.

-DD

Tell the pre-processor to pass all macro definitions to the output

,

Display in the order of appearance

.

-DN

with

`-dd '

Options Similar

,

But ignore macro parameters or content

.

Only displayed at the output

`#define name.

Assembler Option (ASSEMBLER OPTION)

-WA, Option

Put the options

Option

Pass to the assembler

.

in case

Option

Contain a comma

,

Just divide multiple options in a comma

.

Connector Option (Linker Option)

The following options are used for compiler connection destination files

,

When outputting executable files

.

If the compiler does not connect

,

They are meaningless

.

Object-file-name

If some files do not have a particularly clear suffix

A Special Recognized SUFFIX, GCC

I think they are target documents or library files.

(

According to the content

,

Connectors can distinguish between target files and library files

).

in case

GCC

Perform connection operation

,

These target files will become input files for connectors

.

-llibrary

Connection name

Library

Library file

.

The connector finds this library file in the standard search directory, the real name of the library file is `liblibrary.a '. The connector will reference this file as a file name get an accurate description.

Search Directory In addition to some system standard directories, the path specified by the user in `-l 'option is included.

Generally speaking, the file found by this method is the library file - that is, the archive file consisting of the target file. The method of connecting the archive file is: Scan the archive, find some members, the symbols of these members It has been referenced, but it has not been defined. However, if the connector finds a normal target file, not the library file, connect this target file in a usual way. Specify the uniqueness of the `-l 'option and the specified file name The difference is that the `-l option uses` lib 'and `.a' to wrap the library, and search some directories.-Lobjc

This one

-L

Special form for options for connectivity

Objective C

program

.

-NostartFiles

Not connected system standard startup file

,

Standard library files are still using

.

-nostdlib

Do not connect system standard launch files and standard library files

.

Just pass the specified file to the connector

.

-static

Dynamically connected

Dynamic Linking

System

,

Block connectivity libraries

.

This option is invalid on other systems

.

-shared

Generate a shared target file

,

He can connect to other target files to generate executables

.

Only some system support this option

.

-symbolic

When establishing a shared target file

,

Bind the reference to the global symbol

.

Warning for all unable to resolve reference

(

Unless the connection editing option

`-Xlinker -z -xlinker defs'

replace

).

Only some system support this option

.

-XLINKER Option

Put the options

Option

Pass to the connector

.

You can use him to transfer system-specific connection options

, GNU CC

Unable to identify these options

.

If you need to pass the parameters, you must use two `-xlinker ', one pass option, and pass his parameters again. For example, if you pass the` -assert definitions', you must write into `-xlinker -assert-xlinker definitions ', You can't write a `-xlinker" -assert definitions "', because this will pass the entire string as a parameter, obviously this is not the connector looks forward.

-WL, Option

Put the options

Option

Pass to the connector

.

in case

Option

There is a comma

,

Just divide multiple options in a comma

.

-u symbol

Cause the connector to cancel

Symbol

Symbol definition

,

Thus connect the library module to achieve the definition

.

You can use multiple

`-u '

Option

,

Each keep up with different symbols

,

Make the connector to the additional library module

.

Directory Option (Directory Option)

The following options specify the search path

,

Used to find head files

,

Library file

,

Or some members of the compiler

:

-IDIR

Add in the search path list of header files

DIR

table of Contents

.

-I-

Anything

`-I- '

In front

`-I '

Option specified search path only

`#include" file "'

This situation

;

They can't be used to search

`#include '

Head file included

.

If the search path specified by `-i 'option is behind the` -i-' option, you can search all `#include 'instructions in these paths. (Generally, the -i option is useful.)

Also, `-i- 'option prevents the current directory (where to store the current input file) becomes the first choice for search` #include "file"'. There is no way to overcome the effect of `-i- 'option. You can Specify the `-i. 'Search that directory, it is the current directory when calling the compiler. This is not exactly exactly the default behavior of the preprocessor, but the result is usually satisfactory.

`-I- 'does not affect the use of system standard catalog, so` -i-' and `-nostdinc 'is different options. -LDIR

in

`-l '

Add in the search path list of options

DIR

table of Contents

.

-BPREFIX

This option points to where to find executable

,

Library file

,

And compiler their own data files

.

The compiler driver needs to perform some of the subroutines below: `CPP ',` CC1' (or C `cc1plus'),` as' and `ld '. He put Prefix prefixed the prefix of the program that is executed, It may include also include `Machine / Version / '.

For subroutines to be run, the compiler driver first tries to add the `-b 'prefix (if present). If the file is not found, or if you do not specify the` -b' option, the compiler will then test two standard prefixes` / usr / lib / gcc / 'and `/ usr / local / lib / gcc-lib /'. If you still haven't find the required file, the compiler is looking for any prefix in the path specified by` path 'environment variable. File name.

If there is a need, run-time support file `libgcc.a 'is also within the search range of` -b' prefix. If you are not found here, you are looking for the two standard prefix mentioned above, only This is not. If the above method does not find this file, it will not connect to him. Most of the machines, `libgcc.a 'is not a little less.

You can get an approximation effect through environment variables, gcc_exec_prefix; if this variable is defined, its value is prefixed as above. If you specify the `-b 'option and GCC_EXEC_PREFIX variable, the compiler first uses` -b' Options, and then try the environment variable.

WARNING OPTION

Warning is a diagnostic information for program structure

,

The program does not necessarily have an error

,

But there is a risk

,

Or may exist errors

.

The following options control the number and type of warning generated by the GNU CC:

-fsyntax-only

Check the syntax error in the program

,

But do not produce output information

.

-w

Prohibit all warning information

.

-Wno-import

Prohibition of all

#import

Warning information

.

-pedantic

Open complete suit

ANSI C

All warning diagnosis required by the standard

;

Refused to accept procedures with prohibited grammar expansion

.

Regardless of this option, the program that meets the ANSI C standard should be able to be properly compiled (although the very few programs need a `-ansi 'option). However, if this option is not available, some GNU extensions and traditional C features are also supported. Use This option can reject these programs. There is no reason to use this option, and he exists just to meet some nerd (PEDANT).

For alternative keywords (they start and end with `__ ')` -pedant' does not generate warning information. Pedantic does not warn the expression behind __extension__. But only use this in the system header file. Semicament measures, the application is best to avoid.

-pedantic-errors

This option is

`-pedant

similar

,

But display mistakes rather than warning

.

-W

Show additional warning information for the following events

:

*

Non-volatile automatic variable

(Nonvolatile Automatic Variable)

May be called

Longjmp

Changing

.

These warnings occur only when optimizing compile

.

The compiler only knows the call to SetJMP. He cannot know where to call Longjmp, in fact, a signal processing routine can call him anywhere in the program. The result is that even if the program is no problem, you may get a warning. Because you cannot call Longjmp in places that may have problems.

*

Cannot return value

,

Can also not return a function of the value

(

The lack of the end of the function body is considered to not return a function value

)

E.g

,

The following functions will cause this warning:

Foo (a)

{

IF (a> 0)

Return A;

}

due to

GNU CC

I don't know if some functions never return.

(

contain

Abort

with

Longjmp),

Therefore, there may be a false warning

.

*

There is no effect on the left side of the expression statement or comma expression.

Side Effect.

If you want to prevent this warning

,

The unused expression should be forced to convert to

Void

Types of

.

E.g

,

Such expressions

`x [i, j] '

Will lead to warning

,

and

`x [(void) i, j] '

No

.

*

No symbolic number

`> '

or

`<= '

Comparison of zero

.

-WIMPLICIT-INT

WARNING No specified statement

.

-WIMPLICIT-FUNCTION-DECLAration

Warning functions used before the declaration

.

-WIMPLICIT

with

-WIMPLICIT-INT

with

-WImplicit-function-declaration.

-Wmain

If

main

Function declaration or definition into a strange type

,

Warning

.

Typical case

,

This function is used for external connections

,

return

int

Numerical value

,

No parameters

,

Or specify two parameters

.

-Wreturn-Type

If the function defines the return type

,

And the default type is

int

type

,

Warning

.

At the same time, warned those who do not return

Return

Statement

,

If the function they belong is not

Void

Types of

.

-Wunused

If a part variable is not used in addition to the statement

,

Or declare static functions but no definition

,

Or obviously do not use the calculation results of a statement

,

Warning

.

-WSwitch

If a piece

Switch

The parameters of the statement are enumerated types

,

But there is no corresponding

Case

Statement use enumeration elements

,

Warning

(Default

The appearance of statements can prevent this warning

.)

Beyond the scope of enumeration

Case

The statement also causes this warning

.

-Wcomment

If you comment start sequence

`/ * '

In the comment

,

Warning

.

-Wtrigraphs

Warning any appearance

Trigraph (TRIGRAPH)

Suppose they are allowed

).

-Wformat

Check

PRINTF

with

Scanf

Call for functions

,

Confirm the consistency of each parameter type and format string

.

-Wchar-subscripts

WARNING type is

charr

Array subscript

.

This is a common mistake

,

Programmers often forget on some machines

charr

Symbolic

.

-Wuninitialized

Automatic variables before initialization

.

These warnings may only do optimize compilation, because they need data stream information, only to estimate data flow information when optimizing. If you do not specify the `-o 'option, these warnings will not appear.

These warnings are only for variables of the allocated register. Therefore, there is no such thing as the variable that is declared as Volatile, and the variable that has been acquired, or the length is not equal to 1, 2, 4, and 8 bytes. Also also Will not occur on the structure, a combination or array, even if they are in the register.

Note that if a variable only calculates a value that has never been used, this may not be warned. Because such computing has been deleted by data stream analysis before displaying a warning.

These warnings are optional because the GNU CC has not smart to discriminate all the cases, knowing some of the code that looks wrong is actually correct. The following is an example:

{

INT X;

Switch (Y)

{

Case 1: x = 1;

Break;

Case 2: x = 4;

Break;

Case 3: x = 5;

}

Foo (x);

}

in case

y

Always

1, 2

or

3,

Then

x

Will always be initialized

,

but

GNU CC

I don't know this.

.

Below is another universal case

:

{

Int save_y;

IF (change_y) save_y = y, y = new_y;

...

IF (change_y) y = save_y;

}

There is no mistake here

,

Because only set

Save_y

Use him

.

Defining all the functions returned as Volatile avoids some similarities and not warnings

转载请注明原文地址:https://www.9cbs.com/read-45572.html

New Post(0)