Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ acpp(1) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

hc(1)

cc(1)

cpp(1)

m4(1)

acpp(1)

NAME

acpp − the ANSI C preprocessor

SYNOPSIS

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

DESCRIPTION

acpp is the ANSI C preprocessor which is invoked as the first pass of all ANSI C compilations using the cc(1) or hc(1) command.  Thus, the output of acpp is designed to be in a form acceptable as input to the next pass of the ANSI C compiler. 

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

OPTIONS

The following options to acpp are recognized:

-i fileSpecify the input file for acpp to process. 

-o fileSpecify the output file to which the processed input file will be written. 

-CBy default, acpp strips C-style comments.  If the -C option is specified, comments will be preserved. 

-D name[=value]
Define name as if by a #define directive.  If no value is specified, name is defined as 1.  The -D option and the -U option have equal precedence.  That is, if the same name is used in both a -D option and a -U option, the name will be defined or undefined according to the last occurrence of the name in the list. 

-HProduce a list of the files that are included in the compilation (as they are included) with full path names and print it to stderr.  Useful for debugging. 

-I directoryChange the algorithm for searching for #include files whose names do not begin with / to look in directory 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. 

-U1nameRemove any initial definition of name, where name is a reserved symbol that is predefined by acpp.  For a list of symbols that are predefined, refer to the PREDEFINED MACROS section of the hc(1) man page. 

-X [tac]Select one of the three compilation modes supported.  The three modes are:

−Xt ANSI C Transition Mode. 

−Xa ANSI C Mode. 

−Xc ANSI C Conforming Mode. 

Currently, these modes only affect which predefined macros are defined for the compilation.  See the hc(1) man page for a detailed discussion of the meaning of these compilation modes. 

-Y directoryChange the standard default search directory to directory.  By default, the standard default search directory is set to /usr/include. 

-NIf this option is specified, then acpp will not look in the standard default search directory for an include file that cannot be found in the include directories specified by the -I options.  An error message will be generated if the file(s) cannot be located in the specified search path(s). 

-F fileInclude file prior to reading the source file or standard input.  This allows any number of compiler directives or other definitions to be made visible during a compilation.  Only one -F option is allowed. 

All command line options are evaluated first, then any file specified by the -F option is processed, and finally the specified input file or standard input is processed. 

PREDEFINED MACROS

Several special names are predefined by acpp:

__LINE__
is defined as the current line number (as a decimal integer).

__FILE__
is defined as the current file name (as a C string).

__DATE__
is defined as the date of translation of the source file (a character string literal of the form "Mmm dd yyyy", where 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). 

__TIME__
is defined as the time of translation of the source file (a character string literal of the form "hh:mm:ss" as in the time generated by the asctime(3) function). 

__STDC__
is defined to be 1 if the compilation mode is ANSI C Conforming mode.  For all other compilation modes, __STDC__ is defined, but without an explicit value. 

See the -X option above and the PREDEFINED MACROS section of the hc(1) man page for more information. 

The predefined macros can be used anywhere (including in other macros) just as any other defined name.

DIRECTIVES

All acpp directives start with lines begun by the # character.  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 cannot be any space between name and the (.  Replace subsequent instances of name followed by a ( , a list of comma-separated sets of tokens, and a ) with 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 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 acpp).  When the <filename> notation is used, filename is only searched for in the standard places.  See the −I option above for more detail.  File names may contain strings of the form ${name}, where name is the name of an environment variable.  This allows control over which files are included by specifying file names or path names in environment variables prior to the compilation. 

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

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

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

#ifndef name
The lines following will not 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. 

#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 legal in constant-expression (identical to 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. 

#else Reverses the notion of the test directive which matches this directive.  So, if lines previous to this directive are ignored, the following lines will appear in the output, and vice versa. 

#elif
Same as:

     #else
     #if constant-expression

#error [ tokens ]
This directive causes acpp to produce a diagnostic message that includes the specified sequence of tokens. 

#pragma search directory [ , directory ... ]
Specify a search path for include files.  This is a directive version of the -I command line option described above.  The specified directories will be added in the order specified to the end of the current list of search paths. 

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

OPERATORS

acpp recognizes two special operators:

# This operator is often referred to as the "stringization" operator.  If, in a macro replacement list, a parameter is immediately preceded by the # operator, both are replaced by a single character string literal that contains the spelling of the preprocessing token sequence for the corresponding argument.  For example, given the following macro definition:

#define check(x) printf("%s = %d", #x, x)

acpp will replace a reference to the macro of the form check(var) with the token sequence printf("%s = %d", "var", var). 

## This operator is often referred to as the "token pasting" operator.  If, in a macro replacement list, a parameter is immediately preceded or followed by the ## operator, the parameter is replaced by the corresponding macro argument text and "pasted" to the token on the other side of the ## operator.  For example, given the following macro definition:

#define paste(x) va_va_ ## x

acpp will replace a reference to the macro of the form paste(voom) with the new token va_va_voom. 

In addition to the above operators, acpp joins string literals which occur without any intervening non-whitespace tokens.  Thus, the token sequence "fool" "ishness" will become the single token "foolishness" after processing. 
 

FILES

/usr/includestandard directory for #include files

SEE ALSO

hc(1), cc(1), cpp(1), m4(1). 

DIAGNOSTICS

The error messages produced by acpp are intended to be self-explanatory.  The line number and filename where the error occurred are printed along with the diagnostic. 

CX/UX User’s Reference Manual

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