Thursday, 31 August 2017

Preprocessor Directive

A pre-processor directory is a set of text which is start with # symbol. When C source code compile then process of compilation get start from pre-processor directory. It means all pre-processor directories compile before actual compilation.

Preprocessor Directive C Language

  • Header files
  • Macro
  • Conditional Compilation statements

why do we need pre-processor directives

We use pre-processor directives for a variety of things:

1. Macro replacement: To replace a particular text pattern with another one. This achieves one of several things - replace a text pattern with a constant or replace a text pattern with a parameterized expression - #define

2. Define a variable that the per processor can see - #define

3. Includes source code from external files - #include

4. Conditionally exclude a block of code from the original source code that will be subsequently processed by the compiler. This is done using previously defined pre processor variables - #ifdef or #ifndef

Various Pre-processor Directive

Substitutes a preprocessor macro.
Inserts a particular header from another file.
Undefines a preprocessor macro.
Returns true if this macro is defined.
Returns true if this macro is not defined.
Tests if a compile time condition is true.
The alternative for #if.
#else and #if in one statement.
Ends preprocessor conditional.
Prints error message on stderr.
Issues special commands to the compiler, using a standardized 


  1. I have been reading for the past two days about your blogs and topics, still on fetching! Wondering about your words on each line was massively effective. Techno-based information has been fetched in each of your topics. Sure it will enhance and fill the queries of the public needs. Feeling so glad about your article. Thanks…!
    best software testing training in chennai
    best software testing training institute in chennai with placement
    software testing training

    software testing training and placement
    software testing training online
    software testing class
    software testing classes in chennai
    best software testing courses in chennai
    automation testing courses in chennai