preprocessor in c
DESCRIPTION
Preprocessor in C S-TeacherTRANSCRIPT
INTRODUCTION TO C PREPROCESSOR
C Preprocessor
OverviewPreprocessor DirectivesConditional Compilation
Overview
Six phases to execute C:1. Edit2. Preprocess3. Compile4. Link5. Load6. Execute
C Preprocessor
All preprocessor directives begin with #Possible actions
Inclusion of other filesDefinition of symbolic constants & macrosConditional compilation of program codeConditional compilation of preprocessor
directives
Preprocessor Directives
#define for symbolic constants#define identifier text
Creates symbolic constants The “identifier” is replaced by “text” in the
programExample
#define PI 3.14
area = PI * radius * radius; Replaced by “area = 3.14 * radius * radius” by
preprocessor before compilation
Conditional Compilation Controls the execution of preprocessor
directives & compilation of codeDefine NULL, if it hasn’t been defined yet#if !defined(NULL)#define NULL 0
#endifUse to comment out code (for comments)#if 0code prevented from compiling
#endif