Home » C and C++, Tech Corner

Preprocessor Statements

13 October 2009 No Comments Posted By:Dileep
  • Preprocessor – This is a macroprocessor that processes the source program before it is compiled. It is a collection of special statements called preprocesor statements or preprocessor directives.
  • These directives are executed before the C program passes through the compiler.
  • Preprocessor Directives – These are statements which begin with the # symbol placed in the first coloumn.
  • They are placed before the function main().
  • There will be no smicolon at the end of such statements.
  • Three types -
  1. Macro substitution directives
  2. File inclusion directives
  3. Conditional compilation directives

Macro Substitution

  • This is a process of replacing an identifier of a C program by a constant or a symolic constant.
  • This can be accomplished by the directive #define.

File Inclusion

  • This is a process of inserting the external files containing functions or macro definitions into a C program.
  • This process eliminates the job of rewriting the functions or macro definitions.

Conditional Compilation Directives

  • C preprocessor provides a conditional compilation directive which is used to select alternate segments of code in a C program depending upon the condition.
  • The #ifdef, #else, #elis, #endif directives are used for conditional compilation of the program. These are also used with the #define, #ifndef and #undef directives.

<<Previous Post

Next Post>>

Related posts:

  1. Control Statements(Decision Making & Branching)
  2. Constants and Variables
  3. Operators & Expressions
  4. Pointers
  5. Data Files

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>