Pre-Processor Directives

We know that compiler accepts the program written in high level language and converts it into machine language. The C compiler is used to convert all C programs into machine language. The C compiler is made up of two separate programs: the preprocessor and the translator. In this section, we shall concentrate on the first program called preprocessor.
Now, let us see “What is preprocessor?”

Definition: The preprocessor is used automatically by the C compiler to transform all our C programs before compilation. It is a program that accepts a source program with preprocessing statements as the input and produces another source program which will not contain any preprocessing statements. The preprocessing statements also called preprocessor directive starts with symbol ‘#’ in C language.
Now, let us see “What are preprocessor directives?”

Definition: The preprocessor directives are lines included in our programs that start with character #. These lines are not program statements but they are the instructions (also called directives) for the preprocessor. The symbol ‘#’ is followed by an identifier that is a directive name or instruction name. For example,

#define MAX_LENGTH 100
#include <stdio.h>
etc. are all preprocessor directives. A preprocessor directive statement should not end with semicolon and it should not have even comments in that line.
Ex 1: #define MAX_LENGTH 100;
The above statement ends with semicolon and hence it is an error.
Ex 2: #define MAX_LENTH 100 /* It is a symbolic constant */
The above statement is also wrong. Even comments are also not allowed as
part of instruction
Pre-Processor Directives Pre-Processor Directives Reviewed by Unknown on 04:39 Rating: 5

No comments:

Powered by Blogger.