pcc-cpp man page

cpp — C preprocessor

Synopsis

cpp [-ACEMPtVv] [-D macro[=value]] [-d flags] [-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 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.
-D macro[=value]
Create a macro definition before processing any input, as if a

#define macro value

directive had appeared in the source. If value is not set on the command-line, then a value of 1 is used.

-d flags
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.
-I path
Add path to the list of directories searched by the “#include” directive. This may be used to override system include directories (see -S option). -I may be specified multiple times and is cumulative.
-i file
Include a file before processing any input, as if a

#include “file

directive had appeared in the source. -i may 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.
-S path
Add path to the list of system directories searched by the “#include” directive. The -S option may be specified multiple times and is cumulative.
-t
Traditional cpp syntax. Do not define the __TIME__, __DATE__, __STDC__, and __STDC_VERSION__ macros.
-U macro
Undefine a macro before processing any input, as if a

#undef macro

directive had appeared in the source.

-V
Verbose debugging output. -V can be repeated for greater detail. (This is only available if the cpp program was built with PCC_DEBUG defined, 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 the cpp 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 cpp conforms 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

The cpp utility exits with one of the following values:

0
Successfully finished.
1
An error occurred.
2
The -E option was given, and warnings were issued.

See Also

as(1), ccom(1), make(1), pcc(1), asctime(3)

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.

Info

February 26, 2013