Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ cpp(1) — DYNIX/ptx 3.2.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

m4(1)

unifdef(1)

CPP(1)  —  UNIX Programmer’s Manual

NAME

cpp − the C language preprocessor

SYNOPSIS

/lib/cpp [ option ...  ] [ ifile [ ofile ] ]

DESCRIPTION

Cpp is the C language preprocessor which is invoked as the first pass of any C compilation using the cc (1) command.  Thus the output of cpp is designed to be in a form acceptable as input to the next pass of the C compiler.  See m4(1) for a more general macro processor.

Cpp optionally accepts two file names as arguments.  Ifile and ofile are the input and output for the preprocessor, respectively.  They default to standard input and standard output. 

The following options to cpp are recognized:

−C The −C option specifies that all comments are passed along.  Normally, cpp strips C-style comments, except those found on cpp directive lines. 

−Dname

−Dname=def
Predefine name as if by a #define directive.  If no =def is given, name is defined as 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 is undefined regardless of the order of the options.  You can predefine up to 100 names. This limit includes four standard predefined names for each series. The Balance series includes the names ns16000 and ns32000; the Symmetry series includes the names i386 and i387; both series include the names unix and sequent. 

−E This option is ignored, but is included for System V compatibility. 

−f1167 or −fpa
−fpa is a synonym for −f1167 .  This option directs the Symmetry C compiler to produce code for the Weitek 1167 floating-point accelerator.  For Symmetry systems, this is the same as −Ui387 −Dw1167; Balance systems ignore this directive. 

−Idir Change the algorithm for searching for #include files that do not begin with a /.  Normally, names that do not begin with a / are searched for in two directories: /usr/include and /usr/local/include. The −I directive forces cpp to search dir before /usr/include and /usr/local/include. Thus, #include files whose names are enclosed in "" are searched for first in the directory of the file with the #include line, then in directories named in −I options, and last in /usr/include and /usr/local/include. If an #include is enclosed in <>, the directory of the file with the #include line is not searched.  Up to eight −I options can be specified. 

−M Generate makefile dependencies from #include directives.  For example, suppose the file x.c includes the file other/x.h with the following line:

#include "other/x.h"

The file other/x.h includes the file y.h with the following line:

#include "y.h"

Invoking cpp with the −M option on x.c produces the following output:

x.o:x.c
x.o:other/x.h
x.o:other/y.h

−P Preprocess the input without producing the line control information used by the next pass of the C compiler.  This line control information is of the following form:

# 12 foo.c

This tells the compiler and assembler that the next line is line 12 from foo.c.

−R Allow macro recursion.  Ordinarily, cpp detects and aborts recursive macro definitions, such as the following:

#define a a

and

#define a b
#define b a

The −R option allows recursive definition.  This could allow cpp to hang in a recursive definition.  The −R option is included for 4.2/4.3 BSD UNIX compatibility. 

−Uname
Remove any initial definition of name, where name is a reserved symbol that is predefined by the preprocessor.  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 anywhere (including in macros) just as any other defined name.

All cpp directives start with a pound sign (#) in the first column.  Any number of blanks and tabs are allowed between the # and the directive.  The cpp directives are as follows:

#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 left parenthesis Replace subsequent instances of name followed by a left parenthesis a list of comma-separated set of tokens, and a right parenthesis 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, cpp re-starts its scan for names to expand at the beginning of newly created token-string. 

#undef name
Cause the definition of name (if any) to be forgotten from now on. 

#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 searched for in the standard places only.  See the −I option previously for more detail. 

#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 where it comes from.  If filename is not given, the current file name is unchanged. 

#ifdef name
The following lines up to the corresponding #endif appear in the output if name has been defined by a previous #define directive or −D option, or is a predefined name, but has not been undefined by an #undef directive or −U option. 

#ifndef name
The following lines up to the corresponding #endif appear in the output if name has not been defined by a previous #define directive or −D option, and is not a predefined name, or has been undefined by a subsequent #undef directive or −U option. 

#if constant-expression
Subsequent lines up to the corresponding #endif appear in the output if and only if the constant-expression evaluates to non-zero.  All binary non-assignment C operators, the ?: operator, and 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 an #if directive.  Only these operators, integer constants, and names which are known by cpp should be used in constant-expression. In particular, the sizeof operator is not available. 

#endif
Ends a section of lines begun by a test directive (#if, #ifdef, or #ifndef).  Each test directive must have a matching #endif. 

#else Reverses the notion of the test directive which matches this directive.  Therefore, if lines previous to this directive are ignored, the following lines appear in the output; if lines previous to this directive are included in the output, subsequent lines are ignored.  The test directives #ifdef, #ifndef, and #if and the associated #else directives can be nested. 

FILES

/usr/includestandard directory for #include files
/usr/local/includestandard directory for #include files

SEE ALSO

cc(1), m4(1), unifdef(1)

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. 

NOTES

When new-line characters were found in argument lists for macros to be expanded, early UNIX versions of cpp put out the new-lines as they were found and expanded.  The current version of cpp replaces these new-lines with blanks to alleviate problems that the previous versions had when this occurred. 

BUGS

The directive #ident string is accepted by cpp for compatibility with System V.  Cpp passes #ident directives directly through to the C compiler, cc. The Symmetry compiler correctly ignores it; the Balance compiler mishandles it.

4BSD

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