ACPP(5) ACPP(5)
acpp - the ANSI C language preprocessor
The ANSI C language preprocessor, acpp, is invoked as the first pass of
any ANSI C compilation when the cc(1) command is issued with the -acpp or
-oldcpp option. Thus, acpp's output is designed to be in a form
acceptable as input to the next pass of the C compiler. The use of the
acpp command is not recommended, since the functionality of acpp has been
moved into the C front-end and acpp may not be supported in future
releases. See m4(1) for a general macro processor.
This preprocessor is a version of GNU cpp. To see which version, use
acpp -v. The source code to the preprocessor is distributed in 4Dgifts.
This is intended only as a general statement of the preprocessor's
capabilities. For a more precise statement, see the C language standard
(reference cited at the end of this manual page).
The following options are recognized directly by acpp:
-P Preprocess the input without producing the line control
information used by the next pass of the C compiler. The
compiler driver, cc defines appropriate symbols.
-Dname
-Dname=def
Define name with value def as if by a #define. If no =def is
given, name is defined with value 1. The -D option has lower
precedence than the -U option. That is, if the same name is used
in both a -U options and a -D option, the name will be undefined
regardless of the order of the options.
-Idir Change the algorithm for searching for #include files whose names
do not begin with / to look in dir before looking in the
directories on the standard list. Thus #include files whose
names are enclosed in "" will be searched for first in the
directory of the file with the #include line, then in the
directories named in -I options, and last in directories on a
standard list. For #include files whose names are enclosed in
<>, the directory of the file with the #include line is not
searched. If -I is given with no dir, acpp is instructed to
suppress the search of the standard list of include directories
(this form is obsolete, use -nostdinc instead)). This standard
list consists only of /usr/include.
-Uname undefines name, which is only useful if name is defined via -D or
is a predefined name. The order of the -D and -U options is not
significant: the undefines are done after all the -D's and
predefines are applied.
Page 1
ACPP(5) ACPP(5)
-pedantic
All ANSI constraints are obeyed when this is supplied. Howver,
only one #else, or #endif with extra tokens after the name is
reported per included file to reduce the number of error reports
on older header files.
-traditional
Allows dollar($) in identifiers and makes acpp behave like a
traditional C preprocessor as defined in The C Reference Manual.
-M The names of directly included files are printed on standard
output.
-C Comments are retained in the output of acpp.
-nostdinc
The standard places are not searched for include files. Use -I
to specify directories to search.
Ordinarily, only options mentioned on the cc(1) man page are of interest.
However acpp has the following options not recognized by cc which can be
applied with the cc flag prefix -Wp,. For example, to apply the
acpp-only option -Wall, use cc -Wp,-Wall.
-p All ANSI C constraints are obeyed. If supplied twice, #ident
preprocessing directives produce a warning. Any option starting
with -p is considered to mean -pedantic (see above).
-o out_fname
The output is written to out_fname instead of stdout.
-traditional
Allows dollar($) in identifiers and makes acpp behave like a
traditional C preprocessor as defined in Kernighan & Ritchie, First
Edition.
-trigraphs
Turns on processing of trigraphs.
-B Means there is a different, longer, list of default directories to
search. And C++ // is understood as a introducing a comment.
-+ Means there is a different, longer, list of default directories to
search. And C++ // is understood as a introducing a comment.
-Wtrigraphs
Warns if any trigraphs are encountered in the text.
Page 2
ACPP(5) ACPP(5)
-Wcomments
Warns if a comment start is found within a comment.
-Wcomment
Warns if a comment start is found within a comment.
-Wall
is the same as having both -Wtrigraphs and -Wcomments.
-M The names of directly included files are printed on standard output.
-MM The names of included files at all nesting levels are printed on
standard output.
-d Instead of writing the preprocessed file out, write the names and
values of all preprocessor macros defined.
-v prints the GNU CPP version number.
-C Comments are retained in the output of acpp.
-$ Dollar signs are allowed in identifiers.
-nosplice
Turn backslash newline into newline when outputting defines, but
don't consider them to end the macro definition.
-nostdinc
The standard places are not searched for include files. Use -I to
specify directories to search.
-u Inhibits predefinition of values. If not supplied, the names mips
and unix are predefined. cc -ansi passes -u to acpp.
-w Turns off warning messages.
-showdefines
Show each #define (#undef) followed by the line number and file name
where it is appears. The first few defines shown are the predefines
built-in to cpp and passed on the command line (for these the line
number and file name are meaningless). This facility is to assist
you in the special situation where you have a #define (#undef) and
you are having difficulty determining which source file the it is
in. Use any standard text tool to inspect the result file.
Example:
cc -ansi -E -Imyincludedir -Wp,-showdefines myfile.c >myresult
- As a file name, - is treated as a file name (stdin or stdout).
Page 3
ACPP(5) ACPP(5)
Some special names are understood by acpp. The name __LINE__ is defined
as the current line number (as a decimal integer) as known by acpp, and
__FILE__ is defined as the current file name (as a C string) as known by
acpp. The name __DATE__ is defined as the date of translation of the
source file (a character string literal of the form 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). The name __TIME__ is defined as the time of translation of the
source file (a character string literal of the form generated by the
asctime(3) function). They can be used anywhere (including in macros)
just as any other defined name.
To distinguish itself from cpp(1), acpp defines the macro __ANSI_CPP__,
setting its value to one.
All acpp directive lines start with any number of blanks and tabs
followed by #. Any number of blanks and tabs are allowed between the #
and the directive. The directives are:
#define name token-string
Replace subsequent instances of name with token-string.
#define name( arg, ..., arg ) token-string
Notice that there can be no space between name and the (. Replace
subsequent instances of name followed by a (, a list of commaseparated
sets of tokens, and a ) followed by token-string, where
each occurrence of an arg in the token-string is replaced by the
corresponding set of tokens in the comma-separated list. When a
macro with arguments is expanded, the arguments are placed into the
expanded token-string unchanged. After the entire token-string has
been expanded, acpp re-starts its scan for names to expand at the
beginning of the newly created token-string. The # preprocessing
token turns the immediately following argument in token-string into
a string literal (i.e., enclosed in double quotes) which contains
the spelling of the argument (see the example below). The ##
preprocessing token causes the preceeding preprocessing token to be
concatenated with the following preprocessing token into a single
preprocessing token available for further replacement. Either or
both of the preprocessing tokens may be substituted macro arguments.
As an example of the # and ## operators, the sequence
#define quote(arg) # arg
#define glue_to_b(a) a ## b
quote(foo)
glue_to_b(b_follows_me)
creates the output
"foo"
b_follows_meb
Page 4
ACPP(5) ACPP(5)
#undef name
Cause the definition of name (if any) to be forgotten from now on.
No additional tokens are permitted on the directive line after name.
#ident "string"
The string and the directive are silently swallowed. No output is
produced for this directive.
#pragma
The directive and whatever follows it on the line is passed to the
output in a slightly modified form which is not documented. The
form may change in a future release.
#pragma once
If this directive appears in an included file, the file will never
be included again, even if there is another #include of this file.
No tokens or comments are permitted after the ``once'' keyword.
Using #pragma once is more efficient than using macro wrappers,
because the included file is not rescanned, but it may not be
portable to third-party preprocessors.
#include "filename"
#include <filename>
Include at this point the contents of filename (which will then be
run through acpp). When the <filename> notation is used, filename
is only searched for in the standard places. See the -I option
above for more detail. No additional tokens are permitted on the
directive line after the final " or >.
#line integer-constant filename
Causes acpp to generate line control information for the next pass
of the C compiler. Integer-constant is the line number of the next
line and filename is the file from which it comes. If "filename" is
not given, the current file name is unchanged. No additional tokens
are premitted on the directive line after the optional filename.
#endif
Ends a section of lines begun by a test directive (#if, #ifdef, or
#ifndef). Each test directive must have a matching #endif. No
additional tokens are permitted on the directive line. To reduce
the volume of error reports on older header files, acpp reports only
one instance of additional tokens per included file.
#ifdef name
The lines following will appear in the output if and only if name
has been the subject of a previous #define without being the subject
of an intervening #undef. No additional tokens are permitted on the
directive line after name.
Page 5
ACPP(5) ACPP(5)
#ifndef name
The lines following will appear in the output if and only if name
has not been the subject of a previous #define. No additional
tokens are permitted on the directive line after name.
#if constant-expression
Lines following will appear in the output if and only if the
constant-expression evaluates to non-zero. All binary nonassignment
C operators, the ?: operator, the unary -, !, and ~
operators are all legal in constant-expression. The precedence of
the operators is the same as defined by the C language. There is
also a unary operator defined, which can be used in constant-
expression in these two forms: defined ( name ) or defined name.
This allows the utility of #ifdef and #ifndef in a #if directive.
Only these operators, integer constants, and names which are known
by acpp should be used in constant-expression. In particular, the
sizeof operator is not available.
To test whether either of two symbols, foo and fum, are defined,
use:
#if defined(foo) || defined(fum)
#elif constant-expression
This is equivalent to a #else with a #if expression, and is often
more convenient than a nested #else #if constant-expression #endif
#endif.
#else
The lines following will appear in the output if and only if the
preceding test directive evaluates to zero. No additional tokens
are permitted on the directive line. To reduce the volume of error
reports on older header files, acpp reports only one instance of
additional tokens per included file.
The test directives and the possible #else directives can be nested.
#error preprocessing-tokens
The preprocessing tokens are emitted and an error is signaled to cc.
#ident
This System V directive is silently accepted and ignored unless
-pedantic is supplied twice, in which case a warning is issued for
each #ident encountered.
#sccs
This is a BSD-only directive. Use of it is an error.
standard directory list for #include files, /usr/include
Page 6
ACPP(5) ACPP(5)
Two often-used capabilities of the older C preprocessor cpp(1) have a
different syntax in acpp(5). These are enclosing a macro argument in
double-quotes, and concatenating tokens. See the discussion of #define
for the new syntax.
cc(1), line(1), m4(1), cpp(1)
American National Standard for Information Systems - Programming Language
- C, ANSI X3.159-1989.
PPPPaaaaggggeeee 7777 [ Back ]
|