CPP
Section: User Commands (1)
Updated: 30 May 1993
Index
Return to Main Contents
NAME
cpp - a stand-alone C preprocessor
SYNOPSIS
cpp
[
-CTV
] [
-P[012]
] [
-Dname
]
[
-Dname=def
] [
-Idirectory
] [
-Uname
]
[
-ansi
] [
-f[no-]c++-comments
] [
-W[no-]bad-chars
]
[
-W[no-]nested-comments
] [
input-file
[
output-file
] ]
DESCRIPTION
cpp
is a stand-alone C preprocessor, intended for use with C compilers such
as HSC which do not provided access to preprocessor output. It
implements as closely as possible an ANSI standard C preprocessor,
including trigraphs, token pasting and stringizing.
cpp
optionally accepts two filenames as arguments.
input-file
and
output-file
are, respectively, the input and output files for the preprocessor.
If not specified, or if given as `-', they default to the standard
input and the standard output, respectively.
OPTIONS
- -C
-
Pass all comments (except those that appear on
cpp
directive lines) through the preprocessor.
By default,
cpp
strips out C-style comments.
- -P[012]
-
Preprocess the input without producing the line control
information used by the next pass of the C compiler. A numeric argument
can be passed to -P: 0 specifies that no line control information
control is generated, and is equivalent to -P; 1 specifies that normal
line control information is generated, which is the default; and 2
specifies that line control information is generated in the form of
preprocessor
#line
directives.
- -T
-
Translate trigraphs in the input file. This behavior is implied by the
-ansi
option.
- -D name
-
Define
name
as 1 (one).
This is the same as if a
-Dname=1
option appeared on the
cpp
command line, or as if a
-
-
#define name 1
-
line appeared in the source file that
cpp
is processing.
- -Dname=def
-
Define
name
as if by a
#define
directive.
This is the same as if a
-
-
#define name def
-
line appeared in the source file that
cpp
is processing. The
-D
option has lower precedence than the
-U
option; that is, if the same name is used in both a
-U
option and a
-D
option, the name will be undefined regardless of the order of the options.
- -Idirectory
-
Insert
directory
into the search path for
#include
files with names not beginning with
`/', `\\',
or a drive specifier.
directory
is inserted ahead of the standard list of ``include'' directories.
Thus,
#include
files with names enclosed in
double-quotes (")
are searched for first in the directory of the file with the
#include
line, then in directories named with
-I
options, and lastly, in directories from the standard list.
For
#include
files with names enclosed in angle-brackets
(<>),
the directory of the file with the
#include
line is not searched.
See
USAGE
below for exact details of this search order.
- -Uname
-
Remove any initial definition of
name,
where
name
is a symbol that is predefined by the preprocessor.
- -V
-
Print version information to
stderr.
- -ansi
-
Define the preprocessor token
__STDC__
to have value 1, and enable trigraph translation. To get
__STDC__
without trigraph translation, you can specify the options
-ansi
-T.
The following
-f
and
-W
options can be negated by adding a
no-
before the option name. Some are on by default.
- -fc++-comments
-
Support the C++ comment indicator
`//'.
With this option active, everything on the line after the
//
is treated as a comment. Off by default.
- -Wbad-chars
-
Issue a warning if a character that cannot legally appear in a C program
appears in the input. On by default.
- -Wnested-comments
-
Issue a warning if a comment-start character sequence
(`/*',
and
`//'
if
-fc++-comments
is active) appears in a comment. Off by default.
USAGE
If you are familiar with C, you should already know about the basic
workings of
cpp.
We will not go into a detailed description here, since any good book on
C could do better; instead, we will describe details particular to this
implementation.
Directory Search Order
A file specified in an
#include
directive will be searched for in the following directories, in order:
-
- 1.
-
The directory of the file that contains the
#include
directive, if the directive is of the form `#include
``filename'''.
- 2.
-
The directories specified by
-I
options, in the order they were specified.
- 3.
-
The list of directories specified in the
INCLUDE
environment variable, in order.
Special Names
The following macros are predefined by
cpp:
-
- __STDC__
-
Expands to 1 if the
-ansi
option is specified.
- __LINE__
-
Expands to an integer constant representing the current line number in
the current input file.
- __FILE__
-
Expands to a string constant representing the name of the current input
file.
- __DATE__
-
Expands to a string constant of the form "Mmm dd yyyy" representing the
date on which preprocessing was initiated.
- __TIME__
-
Expands to a string constant of the form "hh:mm:ss" representing the
system time at which preprocessing was initiated.
- __INCLUDE_LEVEL__
-
Expands to an integer constant representing the current depth of nested
#include
files.
SEE ALSO
Documentation for your C compiler
Any good book on C.
DIAGNOSTICS
The error messages produced by
cpp
are intended to be self-explanatory. The line number and filename
where the error occurred are printed along with the diagnostic.
BUGS
None that I know of, but there's almost always One More Bug(TM). If you
should find one, please report it to me, Scott Bigham, at
dsb@cs.duke.edu.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- OPTIONS
-
- USAGE
-
- Directory Search Order
-
- Special Names
-
- SEE ALSO
-
- DIAGNOSTICS
-
- BUGS
-
This document was created by
man2html,
using the manual pages.
Time: 23:09:06 GMT, June 28, 2022