pre processor directives in C

2,890 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,890
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
153
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

pre processor directives in C

  1. 1. PREPROCESSORS IN C BY SAHITHI NARAPARAJU
  2. 2. INTRODUCTION:  One of the unique feature of C language is preprocessor.  The preprocessor is a program that processes the source code before it passes through compiler.  Pre processor directives are divided into 3 categories: 1. Macro substitution directives 2. File inclusion directives 3. Compiler control directives
  3. 3. 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 macro definition.  This is achieved by #include directive.
  4. 4. ADDITIONAL PREPROCESSOR DIRECTIVES #ELIF DIRECTIVE: #ELIF enables us to establish an if else if sequence for testing multiple conditions.  #PRAGMA DIRECTIVE: #PRAGMA is an implementation oriented directive that allows us to specify various instructions to be given to compiler. Syntax: #pragma name 
  5. 5. #ERROR : #ERROR directive is used to produce diagnostic messages during debugging. Syntax: #error error message. 
  6. 6. PREPROCESSOR OPERATORS There are 2 preprocessor operations namely: 1. Stringizing operator # 2. Token pasting operator ##  Stringizing operator #: It is used in definition of macro functions. This operator allows a formal argument within a macro definition to be converted to a string. Syntax: #define sum(XY)printf(#xy”=%fn”,xy); 
  7. 7. Token pasting operator ##:  The token pasting operator enables us to combine two tokens within a macro definition to form a single token. Syntax: #define combine(string1,string2) s1##s2.

×