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

Example
  • 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


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


4 comments:

  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
    courses

    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

    ReplyDelete