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 .c are passed via cpp(1) β†’ ccom(1) β†’ as(1) β†’ ld(1).
  • Filenames that end with .i are passed via ccom(1) β†’ as(1) β†’ ld(1).
  • Filenames that end with .s are passed via as(1) β†’ ld(1).
  • Filenames that end with .S are passed via cpp(1) β†’ as(1) β†’ ld(1).
  • Filenames that end with .o are passed directly to ld(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 the cpp(1), ccom(1), as(1), or ld(1) executables.
  • -C β€” passed to the cpp(1) preprocessor so it does not discard comments.
  • -c β€” stop after generating object code with as(1). do not link. the resulting object output gets saved as a filename with a .o suffix, unless you used the -o option. ⚠️ Note: this cannot be combined with -o if multiple files are given.
  • -D macro[=value] β€” passed to the cpp(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 with cpp(1). do not compile, do not assemble, do not link. output goes to standard output unless the -o option 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 treat char types as if they were unsigned unless explicitly defined otherwise. -fsigned-char can be used to signify the opposite behaviour. the default for the char type 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 -g flag to ccom(1) to create debug output. debug information output can be disabled with -g0.
  • -I path β€” passed to the cpp(1) preprocessor to add a header search directory to override the system defaults.
  • -include file β€” tells the cpp(1) preprocessor to include file during preprocessing.
  • -isystem path β€” defines path as a system header directory for the cpp(1) preprocessor.
  • -k β€” generate PIC code. see the -fpic option.
  • -Lpath β€” passed to the linker, to add path to the list of directories searched for shared libraries.
  • -M β€” pass the -M flag to cpp(1) to generate dependencies for make(1).
  • -moption β€” target-dependent options. multiple -m options 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
  • -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 the cpp(1) preprocessor, and passes -xdce, -xdeljumps, -xtemps and -xinline to ccom(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 _PTHREADS preprocessor identifier for cpp(1), and adds -lpthread to the ld(1) linker arguments.
  • -S β€” stop after compilation by ccom(1). do not assemble and do not link. the resulting assembler-language output is saved as a filename with a .s suffix unless the -o option is used. ⚠️ Note: cannot be combined with -o if multiple files are given.
  • -s β€” passed to ld(1) to remove all symbol table and relocation information from the generated executable. this option is silently ignored if cc does 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 are c89, c99, gnu89, gnu99, gnu9x, and c11.
  • -t β€” passed to cpp(1) to suppress some default macro definitions and enable use of traditional C preprocessor syntax.
  • -U macro β€” passes to the cpp(1) preprocessor to remove the initial macro definition.
  • -v β€” outputs the version of cc and shows commands as they are run with their command line arguments. πŸ‘€
  • -### β€” as per -v except 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 are none, c, c++, assembler and assembler-with-cpp. any unknown -x options are passed to ccom(1).
  • -z keyword β€” passed to ld(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 of pcc(1). these macros can be used to select code based on pcc(1) compatibility. see the -v option.
  • __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 -pthread switch is used.
  • __ASSEMBLER__ β€” defined when input files have a .S suffix, or if the -xassembler-with-cpp option 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 βœ¨πŸ¦‹πŸ’–