CPP(1) UNIX Programmer's Manual CPP(1) NAME cpp - C language preprocessor SYNOPSIS /lib/cpp [ option ... ] [ ifile [ ofile ] ] HP-UX COMPATIBILITY Level: HP-UX/STANDARD Origin: System III DESCRIPTION _C_p_p is the C language preprocessor which is invoked as the first pass of any C compilation using the _c_c(1) command. Its purpose is to process include and conditional compila- tion instructions, and macros. The output of _c_p_p is designed to be in a form acceptable as input to the next pass of the C compiler. As the C language evolves, _c_p_p and the rest of the C compilation package will be modified to follow these changes. Therefore, the use of _c_p_p other than in this framework is not suggested. The preferred way to invoke _c_p_p is through the _c_c(1) command, since the func- tionality of _c_p_p may someday be moved elsewhere. _C_p_p optionally accepts two file names as arguments. _I_f_i_l_e and _o_f_i_l_e are respectively the input and output for the preprocessor. They default to standard input and standard output if not supplied. The following _o_p_t_i_o_ns are recognized: -C By default, _c_p_p strips C-style comments. If the -C option is specified, all comments (except those found on _c_p_p directive lines) are passed along. -D_n_a_m_e -D_n_a_m_e=_d_e_f Define _n_a_m_e as if by a #define directive. If no =_d_e_f is given, _n_a_m_e is defined as 1. -H _n_n_n Change the internal macro definition table to be _n_n_n bytes in size. The macro symbol table is increased proportionally. The default table size is 36 000 bytes. This option serves to eliminate the "too many defines" and "too much defining" errors. -I_d_i_r Change the algorithm for searching for #include files whose names do not begin with / to look in _d_i_r 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 _i_f_i_l_e argu- ment, 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 _i_f_i_l_e argument is not searched. However, the directory _d_i_r is searched. -P Preprocess the input without producing the line control information used by the next pass of the C compiler. -T Forces _c_p_p to use only the first eight characters for distinguishing different preprocessor names. This behavior is the same as previous preprocessors with respect to the length of names, and is included for backward compatibility. This option can currently be used only by invoking _c_p_p directly; it cannot be accessed when _c_p_p is invoked through _c_c(1). -U_n_a_m_e Remove any initial definition of _n_a_m_e, where _n_a_m_e is a reserved symbol that is predefined by the particular preprocessor. The current list of these possibly reserved symbols includes: operating system: mert, ibm, gcos, os, tss, unix hardware: hp9000s500, hp9000s200, interdata, pdp11, u370, u3b, vax UNIX System variant: RES, RT, TS, PWB Two special names are understood by _c_p_p. The name __LINE__ is defined as the current line number (as a decimal integer) as known by _c_p_p, and __FILE__ is defined as the current file name (as a C string) as known by _c_p_p. They can be used any- where (including in macros) just as any other defined name. All _c_p_p directives start with lines begun by #. The direc- tives are: #define _n_a_m_e _t_o_k_e_n-_s_t_r_i_n_g Replace subsequent instances of _n_a_m_e with _t_o_k_e_n-_s_t_r_i_n_g (_t_o_k_e_n-_s_t_r_i_n_g may be null). #define _n_a_m_e( _a_r_g, ... , _a_r_g ) _t_o_k_e_n-_s_t_r_i_n_g Replace subsequent instances of _n_a_m_e, followed by (, a list of comma separated tokens, and a ), by _t_o_k_e_n- _s_t_r_i_n_g, where each occurrence of an _a_r_g in the _t_o_k_e_n- _s_t_r_i_n_g is replaced by the corresponding token in the comma separated list. Note that there must be no space between _n_a_m_e and (. #undef _n_a_m_e Cause the definition of _n_a_m_e (if any) to be forgotten from now on. #include "_f_i_l_e_n_a_m_e" #include <_f_i_l_e_n_a_m_e> Include at this point the contents of _f_i_l_e_n_a_m_e (which will then be run through _c_p_p). When the <_f_i_l_e_n_a_m_e> notation is used, _f_i_l_e_n_a_m_e is only searched for in the standard places. See the -I option above for more detail. #line _i_n_t_e_g_e_r-_c_o_n_s_t_a_n_t "_f_i_l_e_n_a_m_e" Cause _c_p_p to generate line control information for the next pass of the C compiler. _I_n_t_e_g_e_r-_c_o_n_s_t_a_n_t is the line number of the next line and _f_i_l_e_n_a_m_e is the file from which it comes. If "_f_i_l_e_n_a_m_e" is not given, the current file name is unchanged. #endif <_t_e_x_t> Ends a section of lines begun by a test directive (#if, #ifdef, or #ifndef). Each test directive must have a matching #endif. Any _t_e_x_t occurring on the same line as the endif is ignored and thus may be used to mark matching if-endif pairs, making it easier to match up endifs with their associated ifs. #ifdef _n_a_m_e The lines following will appear in the output if and only if _n_a_m_e has been the subject of a previous #define without being the subject of an intervening #undef, or if it is a currently defined reserved symbol. #ifndef _n_a_m_e The lines following will not appear in the output if and only if _n_a_m_e has been the subject of previous #define without being the subject of an intervening #undef. #if _c_o_n_s_t_a_n_t-_e_x_p_r_e_s_s_i_o_n Lines following will appear in the output if and only if the _c_o_n_s_t_a_n_t-_e_x_p_r_e_s_s_i_o_n evaluates to non-zero. All binary non-assignment C operators, the ?: operator, the unary -, !, and ~ operators are all legal in _c_o_n_s_t_a_n_t- _e_x_p_r_e_s_s_i_o_n. 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 _c_o_n_s_t_a_n_t- _e_x_p_r_e_s_s_i_o_n in these two forms: defined ( _n_a_m_e ) or defined _n_a_m_e. This allows the utility of #ifdef and #ifndef in a #if directive. Only these operators, integer constants, and names which are known by _c_p_p should be used in _c_o_n_s_t_a_n_t-_e_x_p_r_e_s_s_i_o_n. In particular, the sizeof operator is not available. #else Reverses the notion of the test directive which matches this directive. Thus, if lines previous to this direc- tive are ignored, the following lines will appear in the output, and vice-versa. The test directives and the possible #else directives can be nested. _C_p_p supports _n_a_m_es up to 255 characters long. FILES /usr/include standard directory for #include files SEE ALSO cc(1). DIAGNOSTICS The error messages produced by _c_p_p are intended to be self- explanatory. The line number and filename where the error occurred are printed along with the diagnostic.