CPP(1)
๐ CPP โ the C preprocessor, but make it make sense
okay so bestie, welcome to cpp from the General Commands Manual (section 1, as the header up there says). she's the C preprocessor and she's lowkey iconic. let's get into it โจ
๐ธ NAME ๐ธ
cpp โ the C preprocessor. that's it, that's her. ๐
๐ SYNOPSIS ๐
cpp [-ACEMPtVv] [-D macro[=value]] [-d flags] [-I path] [-i file]
[-S path] [-U macro] [infile | -] [outfile]
like look at all those flags. she's got range. ๐
๐ฆ DESCRIPTION ๐ฆ
So cpp is a macro preprocessor โ she's the one the pcc(1) compiler drags along to do the pre-work. Her main gigs are:
- including header files
- expanding macro definitions
- discarding comments
- doing conditional compilation
and she's written to comply with the ISO/IEC 9899:1999 spec (aka "ISO C99"). no cap, she follows the standard fr fr.
Now, the infile input file? totally optional. if you don't give her one, or if the file name is literally - (just a dash, the loneliest character), cpp reads her initial file from standard input. and the outfile output file? also optional. if you don't hand her one, output goes to standard output. she's flexible like that. ๐ซถ
The options are as follows:
โจ OPTIONS โจ
-Aโ for assembler-with-cpp input: treat non-directive lines that start with a#as comments. little assembler moment. ๐ ๏ธ-Cโ do not discard comments. keep them! she's sentimental. ๐ฌ-Dmacro[=value] โ create a macro definition before processing any input, exactly as if this directive had appeared in the source:
#define macro value
and if you don't set value on the command line? she just uses a value of 1. default queen. 1๏ธโฃ
-dflags โ modify output according to flags, which can be a list of character flags. the flags currently supported are:Mโ do not process any input, but instead output a list of#definestatements for all defined macros other than builtin macros (peep the builtin macros section below ๐).- any unknown flags are just ignored. she's not gonna fight you about it.
-Eโ modify the exit code, if there were any warnings. yes this changes how she clocks out. see EXIT STATUS.-Ipath โ add path to the list of directories searched by the#includedirective. this can be used to override system include directories (see the-Soption).-Ican be specified multiple times and is cumulative. stack 'em up. ๐-ifile โ include a file before processing any input, as if this directive had appeared in the source:
#include "file"
-i can be specified multiple times to include several files. the more the merrier honestly.
-Mโ instead of producing a processed C code file, output a list of dependencies formake(1), detailing the files that need to be processed when compiling the input. very build-system coded of her. ๐๏ธ-Pโ inhibit generation of line markers. this is sometimes useful when running the preprocessor on something that is not C code. she's versatile bestie.-Spath โ add path to the list of system directories searched by the#includedirective. the-Soption may be specified multiple times and is cumulative.-tโ traditionalcppsyntax. this means she does not define the__TIME__,__DATE__,__STDC__, and__STDC_VERSION__macros. going old school, vintage vibes. ๐ฐ๏ธ-Umacro โ undefine a macro before processing any input, as if this directive had appeared in the source:
#undef macro
-Vโ verbose debugging output.-Vcan be repeated for greater detail. (this is only available if thecppprogram was built withPCC_DEBUGdefined, which is the default). she will overshare, and honestly? we love that. ๐ฃ๏ธ-vโ display version.
The-D,-iand-Uoptions are processed in the order that they appear on the command line, before any input is read but after the command line options have been scanned. order matters, bestie. don't @ me.
Files referenced by the #include directive as "..." are first looked for in the current directory, then as per โจ...โฉ files. and โจ...โฉ files are first looked for in the list of directories provided by any -I options, then in the list of system directories provided by any -S options.
โ ๏ธ heads up though:cppdoes not define any include directories by default. if no-Ior-Soptions are given, then only the current directory will be searched and no system files will be found. so like... give her a map, okay? ๐บ๏ธ
๐ฎ Builtin Macros ๐ฎ
a few macros are interpreted inside the cpp program itself. she just knows these. built different.
__DATE__โ expands to a quoted string literal containing the date in the form"Mmm dd yyyy", where the names of the months are the same as those generated by theasctime(3)function, and the first character ofddis a space character if the value is less than 10. tiny formatting detail, huge energy. ๐__FILE__โ expands to a quoted string literal containing the presumed name of the current source file. when reading source from standard input, it expands to"โจstdinโฉ".__LINE__โ expands to an integer constant representing the presumed line number of the source line containing the macro.__STDC__โ expands to the integer constant1, meaning that the compiler conforms to ISO/IEC 9899:1990 (aka "ISO C90").__STDC_VERSION__โ expands to the integer constant199901L, indicating thatcppconforms to ISO/IEC 9899:1999 (aka "ISO C99").__TIME__โ expands to a quoted string literal containing the time in the form"hh:mm:ss"as generated by theasctime(3)function. โฐ
also see the -t option, she mentioned it earlier for a reason.
๐ EXIT STATUS ๐
the cpp utility exits with one of the following values:
0โ Successfully finished. she ate and left no crumbs. โ1โ An error occurred. ๐ญ2โ The-Eoption was given, and warnings were issued. the-Especial. ๐
๐ SEE ALSO ๐
as(1), ccom(1), make(1), pcc(1), asctime(3)
(the whole friend group, honestly. go say hi.)
๐ HISTORY ๐
The cpp command comes from the original Portable C Compiler by S. C. Johnson, written in the late 70's. the code originates from the V6 preprocessor with some additions from V7 cpp and ansi/c99 support. so she's got lore. deep lore. ๐ซก
A lot of the PCC code was rewritten by Anders Magnusson. king behavior.
This product includes software developed or owned by Caldera International, Inc.
okay and that's the whole page bestie!! this one shipped out under Debian, dated February 26, 2013 โ so yeah, vintage, but she still runs circles around everybody. stan cpp. periodt. ๐โจ๐๐ฆ๐ธ๐
๐ซถ
๐ฆ 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