SlideShare a Scribd company logo
3
What is Preprocessor?
 The preprocessor is a program that processes the
source code before it passes through the compiler.
 Produce a source code file with the preprocessing
commands properly sorted out.
Most read
10
Why Macro Expansion is used?
 To write efficient programs.
 To increase readiabiality of programs.
 Variable vs macro_template
 Compiler can generate faster and compact code for
constant than it can for variables.
 When you are dealing with a constant, why use
variable.
 A variable may change in the program.
Most read
12
Why File Inclusion is used?
 Divide a program in multiple files.
 Each file contains related functions.
 Some functions or macros are required in each
program
 Put them in a file (Library).
 Include them in program that need them.
 Nested includes: Included file may have more included
files in it.
Most read
The Preprocessor and Header File
Md. Imran Hossain Showrov (showrovsworld@gmail.com)
21
1
Outline
 What is Preprocessor?
 Preprocessor Directives
 Preprocessor Directives Categories
 Macro Expansion
 File Inclusion
 Conditional compilation
 What is a Header File?
 Why Header Files are used?
What is Preprocessor?
 The preprocessor is a program that processes the
source code before it passes through the compiler.
 Produce a source code file with the preprocessing
commands properly sorted out.
Preprocessor Directives
 Preprocessor commands are known as directives.
 Preprocessor provides certain features.
 These features are also known as preprocessor
directives.
 Preprocessor directives start with # sign.
#include <stdio.h>
Preprocessor Directives (cont..)
 Preprocessor directives can be placed any where in
the source program.
 Note: Place it at start of the program.
 Each preprocessor directive must be on it’s own line.
Preprocessor Directives (cont..)
Preprocessor Directives Categories
 Preprocessor directives can be divided into three
categories:
1. Macro Expansion
2. File Inclusion
3. Conditional compilation (also known as compiler
control directives)
1. Macro Expansion
 #define directive is known as macro expansion.
 Definition:
 General Form:
#define macro_template macro_expansion
#define macro_name char_sequence
1. Macro Expansion (cont..)
 Preprocessor search for macro definition.
 After finding #define directive it search entire
program for macro_template.
 Replace each macro_template with
macro_expansion.
 Best Practice: Use capital letters for macro
template.
 Do not use semicolon ‘ ; ’
Why Macro Expansion is used?
 To write efficient programs.
 To increase readiabiality of programs.
 Variable vs macro_template
 Compiler can generate faster and compact code for
constant than it can for variables.
 When you are dealing with a constant, why use
variable.
 A variable may change in the program.
2. File Inclusion
 causes one file to be included in another.
 <filename> : search the directory on current
directory only.
 “filename” : search the directory on current directory
and specified directories as specified in the include
search path.
Why File Inclusion is used?
 Divide a program in multiple files.
 Each file contains related functions.
 Some functions or macros are required in each
program
 Put them in a file (Library).
 Include them in program that need them.
 Nested includes: Included file may have more included
files in it.
3. Conditional Compilation/ Compiler
Control Directives
 Write single program to run on different
environments.
 #ifdef – if defined
 #endif – end if
 #else – else
 #ifndef – in not defined
 #if – if
 #elif – else if
Where Conditional Compilation is used?
 To avoide multiple declaration error
 Instead of comments(Nested comments not allowed)
 Run the same code on different environment.
What is a Header File?
 A header file is a file with extension .h which contains
C function declarations and macro definitions to be
shared between several source files.
 There are two types of header files:
1. The files that the programmer writes and
2. The files that comes with your compiler.
Why Header Files are used?
 Including a header file is equal to copying the content
of the header file but we do not do it because it will
be error-prone and it is not a good idea to copy the
content of a header file in the source files, especially if
we have multiple source files in a program.
The include syntax
 Both the user and the system header files are included
using the preprocessing directive #include. It has the
following two forms −
 #include <file>
 #include “file”
 Example:
 #include<stdio.h>
 #include<string.h>
Lecture 21 - Preprocessor and Header File

More Related Content

What's hot (20)

Passes of compilers
Passes of compilersPasses of compilers
Passes of compilers
Vairavel C
 
System programming
System programmingSystem programming
System programming
jayashri kolekar
 
Computer Language Translator
Computer Language TranslatorComputer Language Translator
Computer Language Translator
Ranjeet Kumar
 
OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++
Aabha Tiwari
 
Procedural programming
Procedural programmingProcedural programming
Procedural programming
Ankit92Chitnavis
 
Life cycle of a computer program
Life cycle of a computer programLife cycle of a computer program
Life cycle of a computer program
Abhay Kumar
 
Case study
Case studyCase study
Case study
Usha Ravichandran
 
input/ output in java
input/ output  in javainput/ output  in java
input/ output in java
sharma230399
 
Program Threats
Program ThreatsProgram Threats
Program Threats
guestab0ee0
 
Introduction Programming Languages
Introduction Programming LanguagesIntroduction Programming Languages
Introduction Programming Languages
Manish Kharotia
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c language
kamalbeydoun
 
C programming notes
C programming notesC programming notes
C programming notes
Prof. Dr. K. Adisesha
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
Tanzeela_Hussain
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
Dr. C.V. Suresh Babu
 
Compilers
CompilersCompilers
Compilers
Bense Tony
 
File handling in c
File handling in cFile handling in c
File handling in c
David Livingston J
 
Conditional Statement in C#
Conditional Statement in C#Conditional Statement in C#
Conditional Statement in C#
Simplilearn
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming Concepts
Jussi Pohjolainen
 
Function in c
Function in cFunction in c
Function in c
Raj Tandukar
 

Similar to Lecture 21 - Preprocessor and Header File (20)

C language header files
C language header filesC language header files
C language header files
marar hina
 
cppProgramStructure.ppt
cppProgramStructure.pptcppProgramStructure.ppt
cppProgramStructure.ppt
DaveCalapis4
 
6 preprocessor macro header
6 preprocessor macro header6 preprocessor macro header
6 preprocessor macro header
hasan Mohammad
 
C- language Lecture 8
C- language Lecture 8C- language Lecture 8
C- language Lecture 8
Hatem Abd El-Salam
 
Introduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic conceptsIntroduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic concepts
ssuserf86fba
 
Lecture 3 in c ppt
Lecture 3 in c pptLecture 3 in c ppt
Lecture 3 in c ppt
umair ansari
 
Chap 2 structure of c programming dti2143
Chap 2  structure of c programming dti2143Chap 2  structure of c programming dti2143
Chap 2 structure of c programming dti2143
alish sha
 
UNIT 4A-preprocessor.pptx for c language and basic knowledge
UNIT 4A-preprocessor.pptx for c language and basic knowledgeUNIT 4A-preprocessor.pptx for c language and basic knowledge
UNIT 4A-preprocessor.pptx for c language and basic knowledge
2024163103shubham
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
tanmaymodi4
 
Preprocessor directives in c laguage
Preprocessor directives in c laguagePreprocessor directives in c laguage
Preprocessor directives in c laguage
Tanmay Modi
 
google sites coding & programming language.pptx
google sites coding & programming language.pptxgoogle sites coding & programming language.pptx
google sites coding & programming language.pptx
devbhargav1
 
Unit - 5 Lecture – 1 Pre-processor Directives in C.pptx
Unit - 5  Lecture – 1 Pre-processor Directives in C.pptxUnit - 5  Lecture – 1 Pre-processor Directives in C.pptx
Unit - 5 Lecture – 1 Pre-processor Directives in C.pptx
dilipd20
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
sonalikharade3
 
INTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptxINTRODUCTION TO C LANGUAGE.pptx
INTRODUCTION TO C LANGUAGE.pptx
MohammedtajuddinTaju
 
Preprocesser in c++ by thanveer danish
Preprocesser in c++ by thanveer danishPreprocesser in c++ by thanveer danish
Preprocesser in c++ by thanveer danish
Muhammed Thanveer M
 
live journal coding & programming language.pdf
live journal coding & programming language.pdflive journal coding & programming language.pdf
live journal coding & programming language.pdf
devbhargav1
 
Whats a header- Whats a source-code file- Discuss the purpose of each-.docx
Whats a header- Whats a source-code file- Discuss the purpose of each-.docxWhats a header- Whats a source-code file- Discuss the purpose of each-.docx
Whats a header- Whats a source-code file- Discuss the purpose of each-.docx
earleanp
 
blogger coding & programming language.pptx
blogger coding & programming language.pptxblogger coding & programming language.pptx
blogger coding & programming language.pptx
devbhargav1
 
blogger coding & programming language.pdf
blogger coding & programming language.pdfblogger coding & programming language.pdf
blogger coding & programming language.pdf
devbhargav1
 
U get to UnderstandingBasicStructureC.pptx
U get to UnderstandingBasicStructureC.pptxU get to UnderstandingBasicStructureC.pptx
U get to UnderstandingBasicStructureC.pptx
devi96742
 
C language header files
C language header filesC language header files
C language header files
marar hina
 
cppProgramStructure.ppt
cppProgramStructure.pptcppProgramStructure.ppt
cppProgramStructure.ppt
DaveCalapis4
 
6 preprocessor macro header
6 preprocessor macro header6 preprocessor macro header
6 preprocessor macro header
hasan Mohammad
 
Introduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic conceptsIntroduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic concepts
ssuserf86fba
 
Lecture 3 in c ppt
Lecture 3 in c pptLecture 3 in c ppt
Lecture 3 in c ppt
umair ansari
 
Chap 2 structure of c programming dti2143
Chap 2  structure of c programming dti2143Chap 2  structure of c programming dti2143
Chap 2 structure of c programming dti2143
alish sha
 
UNIT 4A-preprocessor.pptx for c language and basic knowledge
UNIT 4A-preprocessor.pptx for c language and basic knowledgeUNIT 4A-preprocessor.pptx for c language and basic knowledge
UNIT 4A-preprocessor.pptx for c language and basic knowledge
2024163103shubham
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
tanmaymodi4
 
Preprocessor directives in c laguage
Preprocessor directives in c laguagePreprocessor directives in c laguage
Preprocessor directives in c laguage
Tanmay Modi
 
google sites coding & programming language.pptx
google sites coding & programming language.pptxgoogle sites coding & programming language.pptx
google sites coding & programming language.pptx
devbhargav1
 
Unit - 5 Lecture – 1 Pre-processor Directives in C.pptx
Unit - 5  Lecture – 1 Pre-processor Directives in C.pptxUnit - 5  Lecture – 1 Pre-processor Directives in C.pptx
Unit - 5 Lecture – 1 Pre-processor Directives in C.pptx
dilipd20
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
sonalikharade3
 
Preprocesser in c++ by thanveer danish
Preprocesser in c++ by thanveer danishPreprocesser in c++ by thanveer danish
Preprocesser in c++ by thanveer danish
Muhammed Thanveer M
 
live journal coding & programming language.pdf
live journal coding & programming language.pdflive journal coding & programming language.pdf
live journal coding & programming language.pdf
devbhargav1
 
Whats a header- Whats a source-code file- Discuss the purpose of each-.docx
Whats a header- Whats a source-code file- Discuss the purpose of each-.docxWhats a header- Whats a source-code file- Discuss the purpose of each-.docx
Whats a header- Whats a source-code file- Discuss the purpose of each-.docx
earleanp
 
blogger coding & programming language.pptx
blogger coding & programming language.pptxblogger coding & programming language.pptx
blogger coding & programming language.pptx
devbhargav1
 
blogger coding & programming language.pdf
blogger coding & programming language.pdfblogger coding & programming language.pdf
blogger coding & programming language.pdf
devbhargav1
 
U get to UnderstandingBasicStructureC.pptx
U get to UnderstandingBasicStructureC.pptxU get to UnderstandingBasicStructureC.pptx
U get to UnderstandingBasicStructureC.pptx
devi96742
 
Ad

More from Md. Imran Hossain Showrov (20)

Lecture 22 - Error Handling
Lecture 22 - Error HandlingLecture 22 - Error Handling
Lecture 22 - Error Handling
Md. Imran Hossain Showrov
 
Lecture 20 - File Handling
Lecture 20 - File HandlingLecture 20 - File Handling
Lecture 20 - File Handling
Md. Imran Hossain Showrov
 
Lecture 19 - Struct and Union
Lecture 19 - Struct and UnionLecture 19 - Struct and Union
Lecture 19 - Struct and Union
Md. Imran Hossain Showrov
 
Lecture 18 - Pointers
Lecture 18 - PointersLecture 18 - Pointers
Lecture 18 - Pointers
Md. Imran Hossain Showrov
 
Lecture 16 - Multi dimensional Array
Lecture 16 - Multi dimensional ArrayLecture 16 - Multi dimensional Array
Lecture 16 - Multi dimensional Array
Md. Imran Hossain Showrov
 
Lecture 17 - Strings
Lecture 17 - StringsLecture 17 - Strings
Lecture 17 - Strings
Md. Imran Hossain Showrov
 
Lecture 15 - Array
Lecture 15 - ArrayLecture 15 - Array
Lecture 15 - Array
Md. Imran Hossain Showrov
 
Lecture 14 - Scope Rules
Lecture 14 - Scope RulesLecture 14 - Scope Rules
Lecture 14 - Scope Rules
Md. Imran Hossain Showrov
 
Lecture 13 - Storage Classes
Lecture 13 - Storage ClassesLecture 13 - Storage Classes
Lecture 13 - Storage Classes
Md. Imran Hossain Showrov
 
Lecture 12 - Recursion
Lecture 12 - Recursion Lecture 12 - Recursion
Lecture 12 - Recursion
Md. Imran Hossain Showrov
 
Lecture 11 - Functions
Lecture 11 - FunctionsLecture 11 - Functions
Lecture 11 - Functions
Md. Imran Hossain Showrov
 
Lecture 10 - Control Structures 2
Lecture 10 - Control Structures 2Lecture 10 - Control Structures 2
Lecture 10 - Control Structures 2
Md. Imran Hossain Showrov
 
Lecture 8- Data Input and Output
Lecture 8- Data Input and OutputLecture 8- Data Input and Output
Lecture 8- Data Input and Output
Md. Imran Hossain Showrov
 
Lecture 9- Control Structures 1
Lecture 9- Control Structures 1Lecture 9- Control Structures 1
Lecture 9- Control Structures 1
Md. Imran Hossain Showrov
 
Lecture 7- Operators and Expressions
Lecture 7- Operators and Expressions Lecture 7- Operators and Expressions
Lecture 7- Operators and Expressions
Md. Imran Hossain Showrov
 
Lecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C ProgrammingLecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C Programming
Md. Imran Hossain Showrov
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language
Md. Imran Hossain Showrov
 
Lecture 4- Computer Software and Languages
Lecture 4- Computer Software and LanguagesLecture 4- Computer Software and Languages
Lecture 4- Computer Software and Languages
Md. Imran Hossain Showrov
 
Lecture 3 - Processors, Memory and I/O devices
Lecture 3 - Processors, Memory and I/O devicesLecture 3 - Processors, Memory and I/O devices
Lecture 3 - Processors, Memory and I/O devices
Md. Imran Hossain Showrov
 
Lecture 2 - Introductory Concepts
Lecture 2 - Introductory ConceptsLecture 2 - Introductory Concepts
Lecture 2 - Introductory Concepts
Md. Imran Hossain Showrov
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language
Md. Imran Hossain Showrov
 
Lecture 3 - Processors, Memory and I/O devices
Lecture 3 - Processors, Memory and I/O devicesLecture 3 - Processors, Memory and I/O devices
Lecture 3 - Processors, Memory and I/O devices
Md. Imran Hossain Showrov
 
Ad

Recently uploaded (20)

TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
Quiz Club of PSG College of Arts & Science
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
LDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad UpdatesLDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad Updates
LDM & Mia eStudios
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
LDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad UpdatesLDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad Updates
LDM & Mia eStudios
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 

Lecture 21 - Preprocessor and Header File

  • 1. The Preprocessor and Header File Md. Imran Hossain Showrov ([email protected]) 21 1
  • 2. Outline  What is Preprocessor?  Preprocessor Directives  Preprocessor Directives Categories  Macro Expansion  File Inclusion  Conditional compilation  What is a Header File?  Why Header Files are used?
  • 3. What is Preprocessor?  The preprocessor is a program that processes the source code before it passes through the compiler.  Produce a source code file with the preprocessing commands properly sorted out.
  • 4. Preprocessor Directives  Preprocessor commands are known as directives.  Preprocessor provides certain features.  These features are also known as preprocessor directives.  Preprocessor directives start with # sign. #include <stdio.h>
  • 5. Preprocessor Directives (cont..)  Preprocessor directives can be placed any where in the source program.  Note: Place it at start of the program.  Each preprocessor directive must be on it’s own line.
  • 7. Preprocessor Directives Categories  Preprocessor directives can be divided into three categories: 1. Macro Expansion 2. File Inclusion 3. Conditional compilation (also known as compiler control directives)
  • 8. 1. Macro Expansion  #define directive is known as macro expansion.  Definition:  General Form: #define macro_template macro_expansion #define macro_name char_sequence
  • 9. 1. Macro Expansion (cont..)  Preprocessor search for macro definition.  After finding #define directive it search entire program for macro_template.  Replace each macro_template with macro_expansion.  Best Practice: Use capital letters for macro template.  Do not use semicolon ‘ ; ’
  • 10. Why Macro Expansion is used?  To write efficient programs.  To increase readiabiality of programs.  Variable vs macro_template  Compiler can generate faster and compact code for constant than it can for variables.  When you are dealing with a constant, why use variable.  A variable may change in the program.
  • 11. 2. File Inclusion  causes one file to be included in another.  <filename> : search the directory on current directory only.  “filename” : search the directory on current directory and specified directories as specified in the include search path.
  • 12. Why File Inclusion is used?  Divide a program in multiple files.  Each file contains related functions.  Some functions or macros are required in each program  Put them in a file (Library).  Include them in program that need them.  Nested includes: Included file may have more included files in it.
  • 13. 3. Conditional Compilation/ Compiler Control Directives  Write single program to run on different environments.  #ifdef – if defined  #endif – end if  #else – else  #ifndef – in not defined  #if – if  #elif – else if
  • 14. Where Conditional Compilation is used?  To avoide multiple declaration error  Instead of comments(Nested comments not allowed)  Run the same code on different environment.
  • 15. What is a Header File?  A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files.  There are two types of header files: 1. The files that the programmer writes and 2. The files that comes with your compiler.
  • 16. Why Header Files are used?  Including a header file is equal to copying the content of the header file but we do not do it because it will be error-prone and it is not a good idea to copy the content of a header file in the source files, especially if we have multiple source files in a program.
  • 17. The include syntax  Both the user and the system header files are included using the preprocessing directive #include. It has the following two forms −  #include <file>  #include “file”  Example:  #include<stdio.h>  #include<string.h>