table of contents
| CPP(1) | General Commands Manual | CPP(1) |
NAME¶
cpp —
SYNOPSIS¶
cpp |
[-ACEMPtVv] [-D
macro[=value]]
[-d flags]
[-I path]
[-i file]
[-S path]
[-U macro]
[infile | -]
[outfile] |
DESCRIPTION¶
Thecpp utility is a macro preprocessor used by the
pcc(1) compiler. It is mainly used to include header files,
expand macro definitions, discard comments, and perform conditional
compilation. cpp is written to comply with the
ISO/IEC 9899:1999 (“ISO C99”)
specification.
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, with output
written to standard output if not provided.
The options are as follows:
-A- For assembler-with-cpp input: treat non-directive lines starting with a # as comments.
-C- Do not discard comments.
-Dmacro[=value]- Create a macro definition before processing any input, as if a
#define macro valuedirective had appeared in the source. If value is not set on the command-line, then a value of 1 is used.
-dflags- Modify output according to flags, which can be a
list of character flags. The following flags are currently supported:
- M
- Do not process any input, but output a list of “#define” statements for all defined macros other than builtin macros (see below).
any unknown flags are ignored.
-E- Modify the exit code, if there were any warnings.
-Ipath- Add path to the list of directories searched by the
“#include” directive. This may be used to override system
include directories (see
-Soption).-Imay be specified multiple times and is cumulative. -ifile- Include a file before processing any input, as if a
#include “file”directive had appeared in the source.
-imay be specified multiple times to include several files. -M- Instead of producing a processed C code file, output a list of dependencies for make(1), detailing the files that need to be processed when compiling the input.
-P- Inhibit generation of line markers. This is sometimes useful when running the preprocessor on something other than C code.
-Spath- Add path to the list of system directories searched
by the “#include” directive. The
-Soption may be specified multiple times and is cumulative. -t- Traditional cpp syntax. Do not define the
__TIME__,__DATE__,__STDC__, and__STDC_VERSION__macros. -Umacro- Undefine a macro before processing any input, as if a
#undef macrodirective had appeared in the source.
-V- Verbose debugging output.
-Vcan be repeated for greater detail. (This is only available if thecppprogram was built withPCC_DEBUGdefined, which is the default). -v- Display version.
The -D, -i and
-U options 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.
Files referenced by the “#include” directive as
“...”, are first looked for in the current directory, then as
per ⟨...⟩ files, which 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. Note that cpp does not define any include
directories by default; if no -I or
-S options are given, then only the current
directory will be searched and no system files will be found.
Builtin Macros¶
A few macros are interpreted inside thecpp program:
- __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 the asctime(3) function, and the first character of dd is a space character if the value is less than 10.
- __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 constant “1”, meaning that the compiler conforms to ISO/IEC 9899:1990 (“ISO C90”).
- __STDC_VERSION__
- Expands to the integer constant “199901L”, indicating that
cppconforms to ISO/IEC 9899:1999 (“ISO C99”). - __TIME__
- Expands to a quoted string literal containing the time in the form “hh:mm:ss” as generated by the asctime(3) function.
Also see the -t option.
EXIT STATUS¶
Thecpp utility exits with one of the following values:
- 0
- Successfully finished.
- 1
- An error occurred.
- 2
- The
-Eoption was given, and warnings were issued.
SEE ALSO¶
as(1), ccom(1), make(1), pcc(1), asctime(3)HISTORY¶
Thecpp 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.
| February 26, 2013 | Linux 4.19.0-10-amd64 |