A preprocessor is a program that converts input data into output that is used as input to another program.


Preprocessing in C++

In C++, conversion of input data is performed on source code before the next step of compilation. This phase of translation is called preprocessing.

Lines beginning with a # sign are directives for the preprocessor. Common directives include the following:

#include

The #include directive copies the full content of a file into the current file. It instructs the preprocessor to treat the contents of a specified file as if those contents had appeared in the source code at the point where the directive appears. The effect is as if the #include directive is replaced by the file specified.

Files copied with the #include directive usually contain headers for library functions and data types, which must be included before they can be used. For this reason, the #include directive usually appears near the beginning of the source code. The files included usually contain header code and are thus called header files.

#define

The #define preprocessor directive declares a constant.


examples #include GCC C++
Borland C++ Compiler
#define GCC C++
Borland C++ Compiler
home Home Page