The Preprocessor

Table of Contents
Usage

vcpp [ -C ] [ -Dname [ =value ] ] [ -E ] [ -Idirectory ] [ -N ] [ -Stext ] [ -Uname ] [ -P ] [ infile [ outfile ] ]

Description

vcpp reads a C/C++ source file, expands macros and include files, and writes an input file for the C/C++ compiler. If no file arguments are given, cpp reads from stdin and writes to stdout. If one file argument is given, it is assumed to be the input file, while two file arguments will be the input and output files. The file name "-" is a synonym for stdin or stdout as appropriate.

There are no target-specific variables defined, since they are expected to be provided using the -D option from the compiler driver. The following are always available unless -N was specified twice: __FILE__ , __LINE__ , __DATE__ and __TIME__ .

vcpp mostly conforms to the ANSI C standard.

Options
   -C
If set, source-file comments are written to the output file. This allows the output of cpp to be used as the input to a program, such as lint, that expects commands embedded in specially-formatted comments.


   -Dname [= value ]
Define the name as if the programmer wrote #define name value at the start of the first file. If = value is not given, a value of 1 will be used.


   -E
Always return "success" to the operating system, even if errors were detected. Note that some fatal errors, such as a missing #include file, will terminate cpp, returning "failure" even if the -E option is given.


   -Idirectory
Add this directory to the list of directories searched for #include "..." and #include <...> commands. Note that there is no space between the "-I" and the directory string. More than one -I command is permitted. On non-Unix systems "directory" is forced to upper-case.


   -N
cpp normally predefines some symbols defining the target computer and operating system. If -N is specified, no symbols will be predefined. If -N -N is specified, the "always present" symbols, __LINE__, __FILE__, and __DATE__ are not defined.


   -Stext
cpp normally assumes that the size of the target computer's basic variable types is the same as the size of these types on the host computer. (This can be overridden when cpp is compiled, however.) The -S option allows dynamic respecification of these values. "text" is a string of numbers, separated by commas, that specifies correct sizes. The sizes must be specified in the exact order:

char short int long float double

If you specify the option as "-S*text", pointers to these types will be specified. -S* takes one additional argument for pointer to function (e.g. int (*)())

For example, to specify sizes appropriate for a PDP-11, you would write:
     c s i l f d func -S1,2,2,2,4,8, -S*2,2,2,2,2,2,2

Note that all values must be specified.


   -Uname
Undefine the name as if #undef name were given. On non-Unix systems, "name" will be forced to upper-case.


   -P
Don't output # line lines and keep heading white space in lines. This option is useful if the output of cpp is fed to a program which would be confused by those lines.


   -M[switch]
Turn itself into dependencies' generator. Valid switches are:
(none)    print to 'makedeps'
+            process system includes
.ext        assume object file extension is .ext
path       print to <path> rather than to 'makedeps'

Known Problems

Many, and probably more than you want to know about. Here are a few: The #if expression processor uses signed integers only. I.e, #if 0xFFFFu < 0 may be true.

If you write

   #define string(arg) "arg"
     ... string("foo") ...

this implementation generates "foo", rather than the strictly correct ""foo"" (which will probably generate an error message).

vcpp does not do inside-out expansion, but outside-in. Unless you start to use quoting, you probably won't see the difference.

There are no trigraphs implemented.