Definitions of c preprocessor

  1. ( cpp) The standard Unixmacro-expansion utility run as the first phase of the Ccompiler, cc. Cpp interprets lines beginning with "#" suchas#define BUFFER_SIZE 256as a textual assignment giving the symbol BUFFER_SIZE avalue " 256". Symbols defined with cpp are traditionally givenupper case names to distinguish them from C identifiers. Thissymbol can be used later in the input, as inchar input_buffer[BUFFER_SIZE]; This use of cpp to name constants, rather than writing thesemagic numbers inline, makes a program easier to read andmaintain, especially if there is more than one occurrence ofBUFFER_SIZE all of which must all have the same value.Cpp macros can have parameters:# define BIT(n) ( 1<<( n)) This can be used with any appropriate actual argument:msb = BIT(nbits-1); Note the parentheses around the " n" in the definition of BIT.Without these, operator precedence might mean that theexpression substituted in place of n might not be interpretedcorrectly ( though the example above would be OK). Cpp also supports conditional compilation with the use of#ifdef SYMBOL...# else...# endifand#if EXPR...# else...# endifconstructs, where SYMBOL is a Cpp symbol which may or may notbe defined and EXPR is an arithmetic expression involving onlyCpp symbols, constants and C operators which Cpp can evaluateto a constant at compile time.Decus cpp is a free implementation for VMS.The most widely used C preprocessor today is the GNU CPP,distributed as part of GCC.