cc
Compile C source code
TLDR
View documentation for the original command
SYNOPSIS
cc [option]... filename... [-o output]
PARAMETERS
-c
Compile to object file (.o), suppress linking
-E
Preprocess only, output to stdout
-g
Generate debugging information
-O[level]
Optimization level (0-3, default 1 with -O)
-o file
Specify output file name
-Wall
Enable most common warnings
-Werror
Treat warnings as errors
-std=standard
Specify ISO C standard (e.g., c99, c11)
-Idir
Add include directory
-Ldir
Add library search directory
-llib
Link with library lib
-Dmacro[=def]
Define macro for preprocessor
-shared
Create shared object
-v
Verbose output, show commands
-pedantic
Issue warnings for standard violations
DESCRIPTION
cc is the traditional Unix command for invoking the C compiler. On modern Linux systems, it is usually a symbolic link to gcc from the GNU Compiler Collection (GCC), though it may point to clang or other implementations. It compiles C source files into object code or executables, handling preprocessing, compilation, assembly, and linking stages unless specified otherwise.
Key features include support for ISO C standards, optimization, debugging symbols, and extensive warnings. Users specify input files (typically .c or .i), options for behavior control, and output via flags. For simple programs: cc file.c -o file produces an executable. Complex projects use it with make or build systems.
It processes multiple files, libraries (-l), include paths (-I), and macros (-D). Output defaults to a.out without -o. cc ensures portability across Unix-like systems per POSIX standards, but actual capabilities depend on the backend compiler.
CAVEATS
Options and behavior depend on underlying compiler (gcc, clang); check man cc or cc --help. Not all flags are portable across systems.
COMMON USAGE
cc -Wall -g -O2 -o prog prog.c
Compiles with warnings, debug, optimization.
cc -c file1.c file2.c
Produces file1.o, file2.o.
EXIT STATUS
0: success
Non-zero: compiler errors or warnings (if -Werror)
HISTORY
Originated in Version 7 Unix (1979) as the first C compiler by Bell Labs. Standardized in POSIX.1-1988; evolved with GCC (1987) for GNU/Linux, supporting modern C11/C17 standards and extensions.


