Encyclopedia > Preprocessor

  Article Content

Preprocessor

A preprocessor is a program that takes text and does lexical conversions to it. The type of lexical conversions may include substitution of macros, conditional inclusion, and inclusion of other files.

The C programming language has a preprocessor that performs the following transformations:

  1. Replaces trigraphs with equivalents.
  2. Concatenates source lines.
  3. Replaces comments with white space.
  4. Reacts to lines starting with an octothorp (#), performing macro substituion, file inclusion, conditional inclusion, and other transformations.

Overuse of the C preprocessor is considered bad style, especially in C++. Stroustrup introduced features such as templates into C++ in an attempt to make the C preprocessor irrelevant; however, his file inclusion alternative was never seriously considered as it was a poor imitation of the C preprocessor's file inclusion mechanism.

Other famous preprocessors include m4 and Oracle Pro*C. The m4 preprocessor is general-purpose; Oracle Pro*C converts embedded PL/SQL into C.

Preprocessing can be quite a cumbersome in incremental parsing[?] or incremental lexial analysis[?] because changes on definition of rules of preprocessing can affect the entire text to be preprocessed.

Example Typical example seen in hello program[?] in C is

#include<stdio.h>

int
main ()
{
  printf ("hello mundo\n");
}
In this case, #include is treated by preprocessor to include a file called stdio.h lexically.



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
North Haven, New York

... age of 18, 3.5% from 18 to 24, 22.3% from 25 to 44, 28.7% from 45 to 64, and 28.1% who are 65 years of age or older. The median age is 50 years. For every 100 females ...

 
 
 
This page was created in 23.4 ms