pre processor directives in CPresentation Transcript
PREPROCESSORS IN C
One of the unique feature of C language is
The preprocessor is a program that processes
the source code before it passes through
Pre processor directives are divided into 3
Macro substitution directives
File inclusion directives
Compiler control directives
MACRO SUBSTITUTION :
Macro substitution is a process where an
identifier in a program replaced by predefined
string composed of one or more tokens.
It is achieved by #define directive.
FILE INCLUSION :
An external file containing functions or macro
definition can be included as apart of program
so that we need not rewrite those function or
This is achieved by #include directive.
#ELIF DIRECTIVE: #ELIF enables us to establish
an if else if sequence for testing multiple
#PRAGMA DIRECTIVE: #PRAGMA is an
implementation oriented directive that allows us to
specify various instructions to be given to
Syntax: #pragma name
#ERROR : #ERROR directive is used to
produce diagnostic messages during
Syntax: #error error message.
There are 2 preprocessor operations namely:
Stringizing operator #
Token pasting operator ##
Stringizing operator #: It is used in definition of
operator allows a formal argument within a macro
definition to be converted to a string.
Token pasting operator ##:
The token pasting operator enables us to
combine two tokens within a macro definition
to form a single token.
#define combine(string1,string2) s1##s2.