1CC(1)                     BSD General Commands Manual                    CC(1)
2

NAME

4     cc — front-end to the C compiler
5

SYNOPSIS

7     cc [-cEgkMPSstvX] [-ansi] [-Bprefix] [-D macro[=value]] [-dflags]
8        [-ffeature] [-I path] [-include file] [-isystem path] [-Lpath]
9        [-moption] [-nodefaultlibs] [-nostartfiles] [-nostdinc] [-nostdlib]
10        [-O[level]] [-o outfile] [-pg] [-pthread] [-shared] [-static]
11        [-std=standard] [-U macro] [-Wa,options] [-Wc,options] [-Wl,options]
12        [-Wp,options] [-x language] [-z keyword] [file ...]
13

DESCRIPTION

15     The cc utility provides a front-end to the “portable C compiler”.  Multi‐
16     ple files may be given on the command line.  Unrecognized options are
17     sent directly to ld(1).
18
19     Filenames that end with .c are passed via cpp(1)ccom(1)as(1)
20     ld(1).
21
22     Filenames that end with .i are passed via ccom(1)as(1)ld(1).
23
24     Filenames that end with .s are passed via as(1)ld(1).
25
26     Filenames that end with .S are passed via cpp(1)as(1)ld(1).
27
28     Filenames that end with .o are passed directly to ld(1).
29
30     The options are as follows:
31
32     -ansi   Synonym for -std=c89.
33
34     -Bprefix
35             Define alternate prefix path for cpp(1), ccom(1), as(1), or ld(1)
36             executables.
37
38     -C      Passed to the cpp(1) preprocessor to not discard comments.
39
40     -c      Stop after generating object code with as(1).  Do not link.  The
41             resulting object output is saved as a filename with a “.o” suffix
42             unless -o option is used.  Note: cannot be combined with -o if
43             multiple files are given.
44
45     -D macro[=value]
46             Passed to the cpp(1) preprocessor to define macro with an
47             optional value.
48
49     -dflags
50             Debug options.  flags is a string of characters, which signify
51             the following actions.
52
53             M  Cause the preprocessor to output a list of macro definitions.
54
55             any unknown flags are ignored.
56
57     -E      Stop after preprocessing with cpp(1).  Do not compile, assemble,
58             or link.  Output is sent to standard output unless the -o option
59             is used.
60
61     -ffreestanding
62             Assume a freestanding environment.
63
64     -fPIC   Generate PIC code.
65
66     -fpic   Tells C compiler to generate PIC code and tells assembler that
67             PIC code has been generated.
68
69     -funsigned-char
70             Tell the compiler to treat ‘char’ types as if they were unsigned
71             unless explicitly defined otherwise.  -fsigned-char can be used
72             to signify the opposite behaviour.  The default for the ‘char’
73             type depends on the compiler target architecture.
74
75     -fstack-protector
76             Tell the compiler to wrap functions with code which checks at
77             runtime that a stack overflow has not occurred.  When stack pro‐
78             tection is in effect, the __SSP__ macro will be defined.
79
80     -g      Send -g flag to ccom(1) to create debug output.  Debug informa‐
81             tion output can be disabled with -g0.
82
83     -I path
84             Passed to the cpp(1) preprocessor to add header search directory
85             to override system defaults.
86
87     -include file
88             Tells the cpp(1) preprocessor to include the file during prepro‐
89             cessing.
90
91     -isystem path
92             Defines path as a system header directory for the cpp(1) pre‐
93             processor.
94
95     -k      Generate PIC code.  See -fpic option.
96
97     -Lpath  Passed to the linker, to add path to the list of directories
98             searched for shared libraries.
99
100     -M      Pass -M flag to cpp(1) to generate dependencies for make(1).
101
102     -moption
103             Target-dependent options.  Multiple -m options can be given, the
104             following are supported:
105
106             ARM      -mlittle-endian -mbig-endian -mfpe=fpa -mfpe=vpf -msoft-
107                      float -march=armv1 -march=armv2 -march=armv2a
108                      -march=armv3 -march=armv4 -march=armv4t -march=armv4tej
109                      -march=armv5 -march=armv6 -march=armv6t2 -march=armv6kz
110                      -march=armv6k -march=armv7
111
112             HPPA
113
114             i386
115
116             MIPS     -mlittle-endian -mbig-endian -mhard-float -msoft-float
117
118             PDP-10
119
120             PowerPC
121
122             Sparc64
123
124             VAX
125
126     -nodefaultlibs
127             Do not link with the system default libraries (libc, etc.)
128
129     -nostartfiles
130             Do not link with the system startup files (crt0.c, etc.)
131
132     -nostdinc
133             Do not use the system include paths (/usr/include, etc.)
134
135     -nostdlib
136             Do not link with the system default libraries or startup files.
137
138     -O[level]
139             Enable compiler optimizations.  Currently, for levels higher than
140             zero, this defines __OPTIMIZE__ in the cpp(1) preprocessor, and
141             passes -xdce, -xdeljumps, -xtemps and -xinline to ccom(1).  If no
142             level is given the optimization level is -O1.  Optimizations can
143             be disabled using -O0.  In situations where multiple optimization
144             flags are given, the last flag is the one used.
145
146     -o outfile
147             Save result to outfile.
148
149     -P      Inhibit generation of line markers in preprocessor output.  This
150             is sometimes useful when running the preprocessor on something
151             other than C code.
152
153     -pg     Enable profiling on the generated executable.
154
155     -pthread
156             Defines the _PTHREADS preprocessor identifier for cpp(1), and
157             adds -lpthread to the ld(1) linker arguments.
158
159     -S      Stop after compilation by ccom(1).  Do not assemble and do not
160             link.  The resulting assembler-language output is saved as a
161             filename with a “.s” suffix unless the -o option is used.  Note:
162             cannot be combined with -o if multiple files are given.
163
164     -s      Passed to ld(1) to remove all symbol table and relocation infor‐
165             mation from the generated executable.  This option is silently
166             ignored if cc does not invoke the linker.
167
168     -shared
169             Create a shared object of the result.  Tells the linker not to
170             generate an executable.
171
172     -static
173             Do not use dynamic linkage.  By default, it will link using the
174             dynamic linker options and/or shared objects for the platform.
175
176     -std=standard
177             Compile to the specified standard.  Accepted values for standard
178             are c89, c99, gnu89, gnu99, gnu9x, and c11.
179
180     -t      Passed to cpp(1) to suppress some default macro definitions and
181             enable use of traditional C preprocessor syntax.
182
183     -U macro
184             Passes to the cpp(1) preprocessor to remove the initial macro
185             definition.
186
187     -v      Outputs the version of cc and shows commands as they are run with
188             their command line arguments.
189
190     -###    As per -v except that the commands are not run, and the arguments
191             will be quoted if they contain unusual characters or spaces.
192
193     -Wa,options
194             Comma separated list of options for the assembler.
195
196     -Wc,options
197             Comma separated list of options for the compiler.
198
199     -Wl,options
200             Comma separated list of options for the linker.
201
202     -Wp,options
203             Comma separated list of options for the preprocessor.
204
205     -X      Don't remove temporary files on exit.
206
207     -x language
208             GCC compatibility option; specify the language in use rather than
209             interpreting the filename extension.  Currently known language
210             values are none, c, c++, assembler and assembler-with-cpp.  Any
211             unknown -x options are passed to ccom(1).
212
213     -z keyword
214             Passed to ld(1).  Please refer to the documentation of your
215             linker for acceptable values of keyword.
216
217   Predefined Macros
218     A few macros are predefined by cc when sent to cpp(1).
219
220     __PCC__  Set to the major version of pcc(1).  These macros can be used to
221     select code based on pcc(1) compatibility.  See the -v option.
222
223     __PCC_MINOR__  Set to the minor version.
224
225     __PCC_MINORMINOR__  Set to the minor-minor version — the number after the
226     minor version.
227
228     _PTHREADS  Defined when -pthread switch is used.
229
230     __ASSEMBLER__  Defined when input files have a .S suffix, or if the
231     -xassembler-with-cpp option is specified.
232
233     Also system- and/or machine-dependent macros may also be predefined; for
234     example: __NetBSD__, __ELF__, and __i386__.
235

SEE ALSO

237     as(1), ccom(1), cpp(1), ld(1)
238

HISTORY

240     The cc command comes from the original Portable C Compiler by S. C.
241     Johnson, written in the late 70's.
242
243     This product includes software developed or owned by Caldera Interna‐
244     tional, Inc.
245
246BSD                              June 20, 2014                             BSD
Impressum