CC(1)
β¨ NAME β¨
cc β front-end to the C compiler π (it lives in the General Commands Manual, aka section 1, aka the iconic one, iykyk)
πΈ SYNOPSIS πΈ
cc [-cEgkMPSstvX] [-ansi] [-Bprefix] [-D macro[=value]] [-dflags]
[-ffeature] [-I path] [-include file] [-isystem path] [-Lpath]
[-moption] [-nodefaultlibs] [-nostartfiles] [-nostdinc] [-nostdlib]
[-O[level]] [-o outfile] [-pg] [-pthread] [-shared] [-static]
[-std=standard] [-U macro] [-Wa,options] [-Wc,options] [-Wl,options]
[-Wp,options] [-x language] [-z keyword] [file ...]
π¦ DESCRIPTION π¦
okay so bestie, cc is literally a front-end to the "portable C compiler". that's the whole vibe. You can hand it multiple files on the command line, no problem. And here's the tea: any option it doesn't recognize? it just yeets it directly to ld(1). not me being a relay π
and now, the way your files get routed depends on their suffix, and this part is important so pay attention:
- Filenames that end with
.care passed viacpp(1)βccom(1)βas(1)βld(1). - Filenames that end with
.iare passed viaccom(1)βas(1)βld(1). - Filenames that end with
.sare passed viaas(1)βld(1). - Filenames that end with
.Sare passed viacpp(1)βas(1)βld(1). - Filenames that end with
.oare passed directly told(1).
the options are as follows, and bestie there are a lot of them, but we're getting through all of them fr fr:
-ansiβ synonym for-std=c89. that's it, that's the whole thing.-Bprefixβ defines an alternate prefix path for thecpp(1),ccom(1),as(1), orld(1)executables.-Cβ passed to thecpp(1)preprocessor so it does not discard comments.-cβ stop after generating object code withas(1). do not link. the resulting object output gets saved as a filename with a.osuffix, unless you used the-ooption. β οΈ Note: this cannot be combined with-oif multiple files are given.-D macro[=value]β passed to thecpp(1)preprocessor to define macro with an optional value.-dflagsβ debug options. flags is a string of characters, and each one signifies an action:Mβ cause the preprocessor to output a list of macro definitions.- any unknown flags are ignored.
-Eβ stop after preprocessing withcpp(1). do not compile, do not assemble, do not link. output goes to standard output unless the-ooption is used.-ffreestandingβ assume a freestanding environment.-fPICβ generate PIC code.-fpicβ tells the C compiler to generate PIC code and tells the assembler that PIC code has been generated.-funsigned-charβ tell the compiler to treatchartypes as if they were unsigned unless explicitly defined otherwise.-fsigned-charcan be used to signify the opposite behaviour. the default for thechartype depends on the compiler target architecture.-fstack-protectorβ tell the compiler to wrap functions with code which checks at runtime that a stack overflow has not occurred. when stack protection is in effect, the__SSP__macro will be defined. π‘οΈ-gβ send the-gflag toccom(1)to create debug output. debug information output can be disabled with-g0.-I pathβ passed to thecpp(1)preprocessor to add a header search directory to override the system defaults.-include fileβ tells thecpp(1)preprocessor to include file during preprocessing.-isystem pathβ defines path as a system header directory for thecpp(1)preprocessor.-kβ generate PIC code. see the-fpicoption.-Lpathβ passed to the linker, to add path to the list of directories searched for shared libraries.-Mβ pass the-Mflag tocpp(1)to generate dependencies formake(1).-moptionβ target-dependent options. multiple-moptions can be given, and the following are supported:- ARM β
-mlittle-endian-mbig-endian-mfpe=fpa-mfpe=vpf-msoft-float-march=armv1-march=armv2-march=armv2a-march=armv3-march=armv4-march=armv4t-march=armv4tej-march=armv5-march=armv6-march=armv6t2-march=armv6kz-march=armv6k-march=armv7 - HPPA
- i386
- MIPS β
-mlittle-endian-mbig-endian-mhard-float-msoft-float - PDP-10
- PowerPC
- Sparc64
- VAX
- ARM β
-nodefaultlibsβ do not link with the system default libraries (libc, etc.)-nostartfilesβ do not link with the system startup files (crt0.c, etc.)-nostdincβ do not use the system include paths (/usr/include, etc.)-nostdlibβ do not link with the system default libraries or startup files. it's giving "I want nothing" π-O[level]β enable compiler optimizations. currently, for levels higher than zero, this defines__OPTIMIZE__in thecpp(1)preprocessor, and passes-xdce,-xdeljumps,-xtempsand-xinlinetoccom(1). if no level is given the optimization level is-O1. optimizations can be disabled using-O0. in situations where multiple optimization flags are given, the last flag is the one used.-o outfileβ save result to outfile.-Pβ inhibit generation of line markers in preprocessor output. this is sometimes useful when running the preprocessor on something other than C code.-pgβ enable profiling on the generated executable.-pthreadβ defines the_PTHREADSpreprocessor identifier forcpp(1), and adds-lpthreadto theld(1)linker arguments.-Sβ stop after compilation byccom(1). do not assemble and do not link. the resulting assembler-language output is saved as a filename with a.ssuffix unless the-ooption is used. β οΈ Note: cannot be combined with-oif multiple files are given.-sβ passed told(1)to remove all symbol table and relocation information from the generated executable. this option is silently ignored ifccdoes not invoke the linker.-sharedβ create a shared object of the result. tells the linker not to generate an executable.-staticβ do not use dynamic linkage. by default, it will link using the dynamic linker options and/or shared objects for the platform.-std=standardβ compile to the specified standard. accepted values for standard arec89,c99,gnu89,gnu99,gnu9x, andc11.-tβ passed tocpp(1)to suppress some default macro definitions and enable use of traditional C preprocessor syntax.-U macroβ passes to thecpp(1)preprocessor to remove the initial macro definition.-vβ outputs the version ofccand shows commands as they are run with their command line arguments. π-###β as per-vexcept that the commands are not run, and the arguments will be quoted if they contain unusual characters or spaces.-Wa,optionsβ comma separated list of options for the assembler.-Wc,optionsβ comma separated list of options for the compiler.-Wl,optionsβ comma separated list of options for the linker.-Wp,optionsβ comma separated list of options for the preprocessor.-Xβ don't remove temporary files on exit. they stay. they live here now π-x languageβ GCC compatibility option; specify the language in use rather than interpreting the filename extension. currently known language values arenone,c,c++,assemblerandassembler-with-cpp. any unknown-xoptions are passed toccom(1).-z keywordβ passed told(1). please refer to the documentation of your linker for acceptable values of keyword.
π Predefined Macros π
a few macros are predefined by cc when sent to cpp(1). little gifts, from us to you π
__PCC__β set to the major version ofpcc(1). these macros can be used to select code based onpcc(1)compatibility. see the-voption.__PCC_MINOR__β set to the minor version.__PCC_MINORMINOR__β set to the minor-minor version β the number after the minor version._PTHREADSβ defined when the-pthreadswitch is used.__ASSEMBLER__β defined when input files have a.Ssuffix, or if the-xassembler-with-cppoption is specified.
also, system- and/or machine-dependent macros may also be predefined; for example: __NetBSD__, __ELF__, and __i386__.
π SEE ALSO π
as(1), ccom(1), cpp(1), ld(1) β the whole squad, go say hi π«Ά
π HISTORY π
the cc command comes from the original Portable C Compiler by S. C. Johnson, written in the late 70's. absolute legend behaviour, no cap π
This product includes software developed or owned by Caldera International, Inc.
and that's the whole page bestie, you ate that π
this was the Debian version of the cc(1) manual, dated June 20, 2014. go compile something iconic β¨π¦π
π¦ where this page comes from
- debian bookworm: pcc 1.2.0~DEVEL+20220331-1 Β· BSD-2-Clause
- debian trixie: pcc 1.2.0~DEVEL+20220331-1 Β· BSD-2-Clause
- ubuntu jammy: pcc 1.2.0~DEVEL+20200630-2 Β· BSD-2-Clause
- ubuntu noble: pcc 1.2.0~DEVEL+20220331-1 Β· BSD-2-Clause
- ubuntu questing: pcc 1.2.0~DEVEL+20220331-2
- ubuntu resolute: pcc 1.2.0~DEVEL+20220331-2build1 Β· BSD-2-Clause
- ubuntu stonking: pcc 1.2.0~DEVEL+20220331-2build1 Β· BSD-2-Clause
- Copyright (c) 2007 Jeremy C. Reed <reed@reedmedia.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms