Compilation can involve up to four stages: preprocessing, compilation proper, assembly and linking, always in that order. The first three stages apply to an individual source file, and end by producing an object file; linking combines all the object files (those newly compiled, and those specified as input) into an executable file.
For any given input file, the file name suffix determines what kind of compilation is done:
file.c
file.i
file.ii
file.m
libobjc.a
to make an Objective-C program work.
file.mi
file.h
file.cc
file.cp
file.cxx
file.cpp
file.c++
file.C
.cxx
,
the last two letters must both be literally x
. Likewise,
.C
refers to a literal capital C.
file.f
file.for
file.FOR
file.F
file.fpp
file.FPP
file.r
See Options Controlling the Kind of Output, for more details of the handling of
Fortran input files.
file.ads
file.adb
file.s
file.S
other
You can specify the input language explicitly with the -x
option:
-x
language
-x
option. Possible values for language are:
c c-header cpp-output c++ c++-cpp-output objective-c objc-cpp-output assembler assembler-with-cpp ada f77 f77-cpp-input ratfor java treelang
-x none
-x
has not been used at all).
-pass-exit-codes
gcc
program will exit with the code of 1 if any
phase of the compiler returns a non-success return code. If you specify
-pass-exit-codes
, the gcc
program will instead return with
numerically highest error produced by any phase that returned an error
indication.
If you only want some of the stages of compilation, you can use
-x
(or filename suffixes) to tell gcc
where to start, and
one of the options -c
, -S
, or -E
to say where
gcc
is to stop. Note that some combinations (for example,
-x cpp-output -E
) instruct gcc
to do nothing at all.
-c
By default, the object file name for a source file is made by replacing
the suffix .c
, .i
, .s
, etc., with .o
.
Unrecognized input files, not requiring compilation or assembly, are
ignored.
-S
By default, the assembler file name for a source file is made by
replacing the suffix .c
, .i
, etc., with .s
.
Input files that don't require compilation are ignored.
-E
Input files which don't require preprocessing are ignored.
-o
file
Since only one output file can be specified, it does not make sense to
use -o
when compiling more than one input file, unless you are
producing an executable file as output.
If -o
is not specified, the default is to put an executable file
in a.out
, the object file for source
.
suffix in
source
.o
, its assembler file in source
.s
, and
all preprocessed C source on standard output.
-v
-###
-v
except the commands are not executed and all command
arguments are quoted. This is useful for shell scripts to capture the
driver-generated command lines.
-pipe
--help
gcc
. If the -v
option is also specified
then --help
will also be passed on to the various processes
invoked by gcc
, so that they can display the command line options
they accept. If the -W
option is also specified then command
line options which have no documentation associated with them will also
be displayed.
--target-help
--version