Scroll to navigation

CPP(1) General Commands Manual CPP(1)

NAME

cppC preprocessor

SYNOPSIS

cpp [-CdMtVv] [-D macro[=value]] [-I path] [-i file] [-S path] [-U macro] [infile | -] [outfile]

DESCRIPTION

The cpp utility is a macro preprocessor used by the pcc(1) compiler. It is used to include header files, expand macro definitions, and perform conditional compilation.

The infile input file is optional. If not provided or the file name is "-" (dash), cpp reads its initial file from standard input. The outfile output file is also optional. It writes by default to standard output.

The options are as follows:

-?
Show command line usage for cpp.
Do not discard comments.
macro[=value]
Fake a definition at the beginning by using “#define macro=value”. If value is not set on command-line, then define it as 1.
Print list of “#define” statements to standard output for all defined macros other than builtin macros (see below). The normal results of preprocessing are not output.
path
Add path to the list of directories containing needed header files. This may be used to override system include directories (see -S option). -I may be specified multiple times.
file
Include a file at the beginning by using “#include file”.
Generate dependencies for make(1).
Inhibit generation of line markers. This is sometimes useful when running the preprocessor on something other than C code.
path
Add path to the list of system directories containing needed header files. The -S option may be specified multiple times. Note: cpp does not have a default include directory defined.
Traditional cpp syntax. Do not define the __TIME__, __DATE__, __STDC__, and __STDC_VERSION__ macros.
macro
Undefine a macro at the beginning by using “#undef macro”.
Verbose debugging output. -V can be repeated for further details.
Display version.

Builtin Macros

A few macros are interpreted inside the cpp program:

__DATE__
Expands to the date in abbreviated month, day, and year format from ctime(3) in quotes.
__FILE__
Expands to the name of the current input file in quotes. When read from standard input, it expands to "⟨stdin⟩".
__LINE__
Expands to the line number of the current line containing the macro.
__STDC__
Expands to the constant 1. This means the compiler conforms to ISO/IEC 9899:1990 (“ISO C90”) (also known as “C90”).
__STDC_VERSION__
Expands to “199901L” which indicates that cpp supports ISO/IEC 9899:1999 (“ISO C99”) (commonly referred to as “C99”).
__TIME__
Expands to the time in hour, minutes, and seconds from ctime(3) in quotes.

Also see the -t option.

EXIT STATUS

The cpp utility exits with one of the following values:

0
Successfully finished.
1
An error occurred.

SEE ALSO

as(1), ccom(1), pcc(1)

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.

A lot of the PCC code was rewritten by Anders Magnusson.

This product includes software developed or owned by Caldera International, Inc.

September 17, 2007 Linux 6.14.1-1-default