Preprocesser in c

muhammedhishammelayi 353 views 12 slides Aug 20, 2014
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

before actual compile.......some .....cont.....


Slide Content

Disclaimer: This presentation is prepared by trainees of baabtra.com as a part of mentoring program. This is not official document of baabtra.com – Mentoring Partner

Preprocessor Directives In C Muhammed Thanveer Melayi Muhammed [email protected] Muhammed Thanveer Melayi Twitter Profile Linkedin Profile

What is Preprocessors The C Preprocessor  is not part of the compiler, but is a separate step in the compilation process. In simplistic terms, a C Preprocessor is just a text substitution tool and they instruct compiler to do required pre-processing before actual compilation All preprocessor commands begin with a pound symbol (#). It must be the first nonblank character, and for readability, a preprocessor directive should begin in first column

 important preprocessor directives Directive and Description The unconditional directives are: #include - Inserts a particular header from another file #define - Defines a preprocessor macro # undef - Undefines a preprocessor macro The conditional directives are: # ifdef - If this macro is defined # ifndef - If this macro is not defined #if - Test if a compile time condition is true #else - The alternative for #if # elif - #else an #if in one statement # endif - End preprocessor conditional Other directives include: # - Stringization , replaces a macro parameter with a string constant ## - Token merge, creates a single token from two adjacent ones

Use of the preprocessor programs easier to develop easier to read easier to modify example # include < stdio.h > #define PI 3.1415 int main () { int radius ; float area; printf ("Enter the radius: "); scanf ("% d",&radius ); area=PI*radius*radius; printf ("Area=%.2f",area ); return ; }

# ifdef and # endif in c It only checks identifier has been defied or not . # ifdef < Identifer >     -------------     ------------- #else     -------------     ------------- # endif Example # include< stdio.h > #define ABC 25 #define PQR "Exact Help" int  main(){      int  num = 3;     # ifdef  ABC          printf ("% d",ABC * ABC);     #else           printf ("% s",PQR );     # endif return  0 ; } Output : 625

# error directive in c Syntax :  #error it only issue an error message and this error message includes . Example #include< stdio.h > # ifndef  __MATH_H #error First include then compile #else int  main(){     float  a,b =25;     a= sqrt (b);     printf ("% f",a );     return 0; } # endif Output: compiler error --> Error directive :First include then compile

Thank you

Want to learn more about programming or Looking to become a good programmer?   Are you wasting time on searching so many contents online? Do you want to learn things quickly? Tired of spending huge amount of money to become a Software professional? Do an online course @  baabtra.com We put industry standards to practice. Our structured, activity based courses are so designed to make a quick, good software professional out of anybody who holds a passion for coding.

Follow us @  twitter.com/ baabtra Like us @ facebook.com/ baabtra Subscribe to us @ youtube.com/ baabtra Become a follower @ slideshare.net/ BaabtraMentoringPartner Connect to us @ in.linkedin.com/in/ baabtra Give a feedback @ massbaab.com/ baabtra Thanks in advance    www.baabtra.com  |  www.massbaab.com  | www.baabte.com

Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam , Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Cafit Square, Hilite Business Park, Near Pantheerankavu , Kozhikode Start up Village Eranakulam , Kerala, India. Email: [email protected] Contact Us
Tags