C Preprocessor Directives – Types of Pre-processor Directives in C Language

Preprocessor Directives in C Language

  • C Preprocessor (in short cpp) is the macro preprocessor (a separate program) which is invoked by the C Compiler before processing any other element in the program i.e. C Preprocessors are the first part of the translation during the processing (Compilation) of a C Program.
  • To include the various instructions to the compiler in the C source code,some directives are used called as Preprocessor Directives.
  • Each preprocessor directive have different task which executes just before the actual execution of C program which makes the program more portable.
  • C Preprocessor directives are used only to instruct compilers.
  • In c all the preprocessor directives start with # characterexcept define() operator.

    C Programming Language
    C Programming Language

Types of Preprocessor Directives in C Language

CONDITIONAL DIRECTIVE          # if     #elif   #else
                               #endif   #ifdef  #ifndef
MISCELLANEOUS DIRECTIVE        #pragma  #line   #error
OPERATOR IN PREPROCESSOR       #,##,define()
  • Spaces or tabs are permitted between the # and directive name (such as inculde,define etc), but no any escape characters or other symbols are permitted. The preprocessor removes white space and concatenates the # and directive name together.

Each Preprocessor Directive would be explained in next posts of C Programming Language.

Leave a Reply

CommentLuv badge