vi Ma
This commit is contained in:
parent
0d6f436e2f
commit
40a36c570e
1 changed files with 31 additions and 159 deletions
190
util/cpp/cpp.6
190
util/cpp/cpp.6
|
@ -1,57 +1,47 @@
|
||||||
.TH CPP VI
|
.TH CPP 6ACK
|
||||||
.SH NAME
|
.SH NAME
|
||||||
cpp \- C Pre-Processor
|
cpp \- C Pre-Processor
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
cpp [\-options] files
|
cpp [\-options] [ file ]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.I Cpp
|
.I Cpp
|
||||||
reads one or more files, expands macros and include
|
reads a file, expands macros and include
|
||||||
files, and writes an input file for the C compiler.
|
files, and writes an input file for the C compiler.
|
||||||
All output is to cpp.tmp (cpp.tmp.c on Unix).
|
All output is to standard output.
|
||||||
.br
|
.br
|
||||||
The following options are supported. On non-Unix systems,
|
The following options are supported.
|
||||||
options may be given in either case.
|
.IP -\fBI\fIdirectory\fR
|
||||||
.IP -Ofile
|
.br
|
||||||
Output to this file, instead of the default.
|
add this directory to the list of
|
||||||
.IP -S
|
|
||||||
Output to stdout, instead of the default.
|
|
||||||
.IP -Idirectory
|
|
||||||
Add this directory to the list of
|
|
||||||
directories searched for #include "..." and #include <...>
|
directories searched for #include "..." and #include <...>
|
||||||
commands. Note that there is no space between the
|
commands. Note that there is no space between the
|
||||||
"-I" and the directory string. More than one -I command
|
"-I" and the directory string. More than one -I command
|
||||||
is permitted.
|
is permitted.
|
||||||
.IP -L
|
.IP -\fBI\fR
|
||||||
.I Cpp
|
end the list of directories to be searched, and also do not look in
|
||||||
transmits line number information to
|
default places.
|
||||||
the C compiler by outputting "#line <number>" records.
|
.IP -\fBD\fIname\fR=\fItext\fR
|
||||||
If the -L option is given, this record will be transmitted
|
|
||||||
as "#", allowing the output of
|
|
||||||
.I cpp
|
|
||||||
to be input to a compiler
|
|
||||||
without an intervening preprocessor without error.
|
|
||||||
.IP -Dname=value
|
|
||||||
Define the name as if the programmer wrote
|
|
||||||
.br
|
.br
|
||||||
.nf
|
define
|
||||||
#define name value
|
.I name
|
||||||
.fi
|
as a macro with
|
||||||
|
.I text
|
||||||
|
as its replacement text.
|
||||||
|
.IP -\fBD\fIname\fR
|
||||||
|
the same as -\fBD\fIname\fR=1.
|
||||||
|
.IP
|
||||||
|
.IP -\fBU\fIname\fR
|
||||||
.br
|
.br
|
||||||
at the start of the first file. If "=value" is not
|
undefine the macro name
|
||||||
given, a value of "1" will be used.
|
.IR name .
|
||||||
.br
|
.IP -\fBC\fR
|
||||||
On non-unix systems, all alphabetic text will be forced
|
leave comments in. By default, C-comments are deleted.
|
||||||
to upper-case.
|
.IP -\fBP\fR
|
||||||
.br
|
do not generate line directives
|
||||||
.IP -Uname
|
.IP -\fBM\fIn\fR
|
||||||
Undefine the name as if
|
set maximum identifier length to
|
||||||
.br
|
.IR n .
|
||||||
.nf
|
.PP
|
||||||
#undef name
|
|
||||||
.fi
|
|
||||||
.br
|
|
||||||
were given. On non-Unix systems, "name" will be forced to
|
|
||||||
upper-case.
|
|
||||||
The following names are always available unless undefined:
|
The following names are always available unless undefined:
|
||||||
.RS
|
.RS
|
||||||
.IP __FILE__
|
.IP __FILE__
|
||||||
|
@ -63,121 +53,3 @@ The line number being compiled.
|
||||||
The date and time of compilation as
|
The date and time of compilation as
|
||||||
a Unix ctime quoted string (the trailing newline is removed).
|
a Unix ctime quoted string (the trailing newline is removed).
|
||||||
.RE
|
.RE
|
||||||
Thus,
|
|
||||||
.br
|
|
||||||
.nf
|
|
||||||
printf("Bug at line %s,", __LINE__);
|
|
||||||
printf(" source file %s", __FILE__);
|
|
||||||
printf(" compiled on %s", __DATE__);
|
|
||||||
.fi
|
|
||||||
.IP
|
|
||||||
-Xnumber
|
|
||||||
Enable debugging code. If no value is
|
|
||||||
given, a value of 1 will be used. (For maintenence of
|
|
||||||
.I cpp
|
|
||||||
only.)
|
|
||||||
.SH "COMMENTS IN MACRO TEXT AND ARGUMENT CONCATENATION"
|
|
||||||
.br
|
|
||||||
Comments are removed from the input text. The comment
|
|
||||||
characters serve as an invisible token delimiter. Thus,
|
|
||||||
the macro
|
|
||||||
.nf
|
|
||||||
#define CAT(a, b) b/**/a
|
|
||||||
int value = CAT(1, 2);
|
|
||||||
.fi
|
|
||||||
Will generate "int value = 21;".
|
|
||||||
.br
|
|
||||||
A better way of concatenating arguments is as follows:
|
|
||||||
.nf
|
|
||||||
#define I(x)x
|
|
||||||
#define CAT(x,y)I(x)y
|
|
||||||
int value = CAT(1, 2);
|
|
||||||
.fi
|
|
||||||
If the above macros are defined without extraneous
|
|
||||||
spaces, they will be transportable to other implementations.
|
|
||||||
.br
|
|
||||||
.SH DIFFERENCES
|
|
||||||
.br
|
|
||||||
The following is a list of differences between this
|
|
||||||
pre-processor and the Unix V7 preprocessor which was
|
|
||||||
written by John Reiser. It is probably not complete.
|
|
||||||
.IP o
|
|
||||||
Macro formal parameters are recognized within
|
|
||||||
quoted strings and character constants in macro definitions.
|
|
||||||
For example,
|
|
||||||
.nf
|
|
||||||
#define foo(a) "Today is a"
|
|
||||||
printf(foo(tuesday));
|
|
||||||
.fi
|
|
||||||
Would print "Today is tuesday".
|
|
||||||
.br
|
|
||||||
Recognition of formal parameters in macro replacement
|
|
||||||
strings is not permitted by the Draft ANSI C Standard.
|
|
||||||
It is permitted in this implementation if cpp was
|
|
||||||
compiled with the STRING_FORMAL parameter set appropriately.
|
|
||||||
.br
|
|
||||||
Unlike Reiser's implementation, the '\e' "quote next character"
|
|
||||||
does just that. I.e.
|
|
||||||
.nf
|
|
||||||
#define foo(a) "Today is \ea a"
|
|
||||||
printf(foo(tuesday));
|
|
||||||
.fi
|
|
||||||
Would print "Today is a tuesday". Note that this may
|
|
||||||
not be portable.
|
|
||||||
.IP o
|
|
||||||
Reiser's implementation removes "escaped" linefeeds
|
|
||||||
(The two character sequence \e<LF>) within macros. This
|
|
||||||
implementation preserves them. For example, a macro which
|
|
||||||
generates control commands might be written
|
|
||||||
.nf
|
|
||||||
#define foo(a, b) \e
|
|
||||||
#define a b \e
|
|
||||||
.fi
|
|
||||||
.nf
|
|
||||||
foo(fubar, foobar)
|
|
||||||
int fubar;
|
|
||||||
.fi
|
|
||||||
The above would generate "int foobar;" and a warning message.
|
|
||||||
Reiser's scan is slightly different.
|
|
||||||
.SH "ANSI C STANDARD"
|
|
||||||
.I Cpp
|
|
||||||
implements most of the ANSI draft standard.
|
|
||||||
You should be aware of the following:
|
|
||||||
.IP o
|
|
||||||
In the draft standard, the \en (backslash-newline)
|
|
||||||
character is "invisible" to all processing. In this implementation,
|
|
||||||
it is invisible to strings, but acts a "whitespace" (token-delimiter)
|
|
||||||
outside of strings. This considerably simplifies error
|
|
||||||
message handling.
|
|
||||||
.IP o
|
|
||||||
The following extensions to C are processed by cpp:
|
|
||||||
.nf
|
|
||||||
.sp 1
|
|
||||||
.ta 4n 27n
|
|
||||||
#elif expression (#else #if)
|
|
||||||
'\exNNN' (Hexadecimal constants)
|
|
||||||
'\ea' (Ascii BELL)
|
|
||||||
'\ev' (Ascii VT)
|
|
||||||
#if defined NAME (1 if defined, 0 if not)
|
|
||||||
#if defined (NAME) (1 if defined, 0 if not)
|
|
||||||
unary + (gag me with a spoon)
|
|
||||||
.fi
|
|
||||||
.IP o
|
|
||||||
The draft standard has extended C, adding a string
|
|
||||||
concatenation operator, where
|
|
||||||
.br
|
|
||||||
.nf
|
|
||||||
"foo" "bar"
|
|
||||||
.fi
|
|
||||||
.br
|
|
||||||
is regarded as the single string "foobar". It is not clear
|
|
||||||
from the draft standard whether this applies to pre-processing
|
|
||||||
if macro formals are recognized in strings.
|
|
||||||
.SH "ERROR MESSAGES"
|
|
||||||
.br
|
|
||||||
Many.
|
|
||||||
.br
|
|
||||||
.SH AUTHOR
|
|
||||||
.br
|
|
||||||
Martin Minow
|
|
||||||
.br
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue