0% found this document useful (0 votes)
41 views6 pages

Separate Step in The Compilation Process: Substitution Tool Pre-Processing

The preprocessor directives instruct the compiler to perform preprocessing tasks before compilation. The preprocessor is not part of the compiler. Preprocessor commands begin with the # symbol. Common directives include #define for defining macros, #include for including header files, and conditional compilation directives like #ifdef and #endif for conditionally including code. Other directives are #undef for undefining macros and #pragma for issuing special commands to the compiler.

Uploaded by

sabapathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views6 pages

Separate Step in The Compilation Process: Substitution Tool Pre-Processing

The preprocessor directives instruct the compiler to perform preprocessing tasks before compilation. The preprocessor is not part of the compiler. Preprocessor commands begin with the # symbol. Common directives include #define for defining macros, #include for including header files, and conditional compilation directives like #ifdef and #endif for conditionally including code. Other directives are #undef for undefining macros and #pragma for issuing special commands to the compiler.

Uploaded by

sabapathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

UNIT-V

Preprocessor Directives

• The C Preprocessor is not a part of the


compiler, but is a separate step in the
compilation process.
• In simple terms, a C Preprocessor is just a text
substitution tool and it instructs the compiler
to do required pre-processing before the
actual compilation.
• All preprocessor commands begin with a hash
symbol (#).
Preprocessor Syntax/Description
Syntax: #define
Macro This macro defines constant value and can be any
of the basic data types.
Syntax: #include <file_name>,
#include"filename"
Header file inclusion The source code of the file “file_name” is
included in the main program at the specified
place.

Syntax: #ifdef, #endif, #if, #else, #ifndef


Set of commands are included or excluded in
Conditional compilation
source program before compilation with respect to
the condition.

Syntax: #undef, #pragma
#undef is used to undefine a defined macro
Other directives
variable. #Pragma is used to call a function before
and after main function in a C program.
Sr.No. Directive & Description
1 #define
Substitutes a preprocessor macro.

2 #include
Inserts a particular header from another file.

3 #undef
Undefines a preprocessor macro.

4 #ifdef
Returns true if this macro is defined.

5 #ifndef
Returns true if this macro is not defined.

6 #if
Tests if a compile time condition is true.

7 #else
The alternative for #if.
8 #elif
#else and #if in one statement.

9 #endif
Ends preprocessor conditional.

10 #error
Prints error message on stderr.

11 #pragma
Issues special commands to the compiler, using a standardized
method.

You might also like