Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

lint(1)

m4(1)



          CPP(1)               INTERACTIVE UNIX System               CPP(1)



          NAME
               cpp - the C language preprocessor

          SYNOPSIS
               LIBDIR/cpp [option ...] [ifile [ofile]]

          DESCRIPTION
               The C language preprocessor, cpp, is invoked as the first
               pass of any C compilation by the cc(1) command.  Thus cpp's
               output is designed to be in a form acceptable as input to
               the next pass of the C compiler.  As the C language evolves,
               cpp and the rest of the C compilation package will be modi-
               fied to follow these changes.  Therefore, the use of cpp
               other than through the cc(1) command is not suggested, since
               the functionality of cpp may someday be moved elsewhere.
               See m4(1) for a general macro processor.

               The cpp command optionally accepts two file names as argu-
               ments.  Ifile and ofile are respectively the input and out-
               put for the preprocessor.  They default to standard input
               and standard output if not supplied.

               The following options to cpp are recognized:

               -P   Preprocess the input without producing the line control
                    information used by the next pass of the C compiler.

               -C   By default, cpp strips C-style comments.  If the -C
                    option is specified, all comments (except those found
                    on cpp directive lines) are passed along.

               -Uname
                    Remove any initial definition of name, where name is a
                    reserved symbol that is predefined by the particular
                    preprocessor.  Following is the current list of these
                    possibly reserved symbols.  On the 80386, unix and i386
                    are defined.
                         operating system:      unix, dmert, gcos, ibm, os,
                                                tss
                         hardware:              i286, i386, interdata,
                                                pdp11, u370, u3b, u3b5,
                                                u3b2, u3b15, u3b20d, vax
                         UNIX system variant:   RES, RT
                         lint(1):               lint

               -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 option and a
                    -D option, the name will be undefined regardless of the
                    order of the options.


          Rev. C Software Development Set                            Page 1





          CPP(1)               INTERACTIVE UNIX System               CPP(1)



               -T   The -T option forces cpp to use only the first eight
                    characters to distinguish preprocessor symbols and is
                    included for backward compatibility.

               -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 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.

               -Ydir
                    Use directory dir in place of the standard list of
                    directories when searching for #include files.

               -H   Print, one per line on standard error, the path names
                    of included files.

               Two special names are understood by cpp.  The name __LINE__
               is defined as the current line number (as a decimal integer)
               as known by cpp, and __FILE__ is defined as the current file
               name (as a C string) as known by cpp. They can be used any-
               where (including in macros) just as any other defined name.

               All cpp directive lines start with # in column 1.  Any
               number of blanks and tabs is 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 comma-separated sets of tokens, and a )
                    followed with token-string.  Each occurrence of an arg
                    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, cpp re-starts its scan for names to
                    expand at the beginning of the newly created token-
                    string.

               #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.


          Rev. C Software Development Set                            Page 2





          CPP(1)               INTERACTIVE UNIX System               CPP(1)



               #ident "string"
                    Put string into the .comment section of an object file.

               #include "filename"
               #include <filename>
                    Include at this point the contents of filename (which
                    will then be run through cpp).  When the <filename>
                    notation is used, filename is only searched for in the
                    standard places.  See the -I and -Y options above for
                    more detail.  No additional tokens are permitted on the
                    directive line after the final " or >.

               #line integer-constant "filename"
                    Causes cpp 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 permitted 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.

               #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.

               #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 non-assignment 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 cpp
                    should be used in constant-expression.  In particular,


          Rev. C Software Development Set                            Page 3





          CPP(1)               INTERACTIVE UNIX System               CPP(1)



                    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
                    An arbitrary number of #elif directives is allowed
                    between a #if, #ifdef, or #ifndef directive and a #else
                    or #endif directive.  The lines following the #elif
                    directive will appear in the output if and only if the
                    preceding test directive evaluates to zero, all inter-
                    vening #elif directives evaluate to zero, and the
                    constant-expression evaluates to non-zero.  If
                    constant-expression evaluates to non-zero, all succeed-
                    ing #elif and #else directives will be ignored.  Any
                    constant-expression allowed in a #if directive is
                    allowed in a #elif directive.

               #else
                    The lines following will appear in the output if and
                    only if the preceding test directive evaluates to zero,
                    and all intervening #elif directives evaluate to zero.
                    No additional tokens are permitted on the directive
                    line.

                    The test directives and the possible #else directives
                    can be nested.

               #pragma pack([1|2|4])
                    If an argument is present, subsequent structures will
                    be aligned to the given byte boundary. The packing of
                    structure members remains in effect until changed or
                    disabled. If no argument is present and the -Zp option
                    was used with the cc command, packing reverts to the
                    packing specified on the cc command line. If the -Zp
                    option was not used with the cc command, structures are
                    aligned to their normal settings.

          FILES
               INCDIR         standard directory list for #include files,
                              usually /usr/include

               LIBDIR         usually /lib

          SEE ALSO
               cc(1), lint(1), m4(1).

          DIAGNOSTICS
               The error messages produced by cpp are intended to be self-
               explanatory.  The line number and file name where the error
               occurred are printed along with the diagnostic.



          Rev. C Software Development Set                            Page 4





          CPP(1)               INTERACTIVE UNIX System               CPP(1)



          NOTES
               The unsupported -W option enables the #class directive.  If
               it encounters a #class directive, cpp will exit with code 27
               after finishing all other processing.  This option provides
               support for ``C with classes.''

               Because the standard directory for included files may be
               different in different environments, this form of #include
               directive:

                    #include <file.h>

               should be used, rather than one with an absolute path, like:

                    #include "/usr/include/file.h"

               The cpp command warns about the use of the absolute path
               name.





































          Rev. C Software Development Set                            Page 5



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026