Teach Time Encyclopedia - Learn About Our World
Home Page
Teach Time
Featured Topics

United States
by state

CITYology

Academic Disciplines

Historical Timelines

Themed Timelines

Calendars

Reference Tables

Biographies

How-tos



Tuesday, October 07, 2008

Preprocessor

A preprocessor is a program that takes text and performs lexical conversions on it. The conversions may include macro substitution, conditional inclusion, and inclusion of other files.

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

  1. Replaces trigraphss with equivalents.
  2. Concatenates source lines.
  3. Replaces comments with whitespace.
  4. Reacts to lines starting with an octothorp (#), performing macro substitution, 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 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 cumbersome in incremental parsing or incremental lexical analysis because changes to preprocessing rules can affect the entire text to be preprocessed.

C Example

A typical example in C is:

\r\n#include \r\n\r\nint main (void)\r\n{\r\n    printf("Hello, world!\\n");\r\n    return 0;\r\n}\r\n
The preprocessor replaces the line #include <stdio.h> with the system header file of that name, which facilitates use of the printf() function.


Internet Hotel Solutions

Site Sponsors
AC Units
Baltimore Harbor
Boot Camp Grads
Bra Size
Burkittsville
College Hotels
Digital Harbor
Free Cell Phones
Golden Hare Travel
Golf Vacations
Golf Courses
Gourmet
Hair Styles
Hippodrome
iWoman
Lesson Plans
Maryland Hotels
MD Genealogy
Minor League Stuff
Motel Site
Ocean City
OC Real Estate
Old Agers
Office Supplies
Orlando
Pet Friendly Hotel
Room Prices
Savannah, GA
Ski Vacations
South Baltimore
Student Teaching
Travel Sources
University Hotels
Visit Military Bases
Washington, DC

Brought to you by NoChildLeftBehind.com and the Beaches and Towns Network, LLC.