Before a C program is compiled in a compiler, source code is processed
by a program called preprocessor. This process is called preprocessing.
The C Preprocessor is not a part of the compiler, but is a separate step in the compilation process.
C Preprocessor directives: Before a C program is compiled in a compiler, source code is processed by a program called preprocessor. This process is called preprocessing. Commands used in preprocessor are called preprocessor directives and they begin with “#” symbol.
Commands used in preprocessor are called preprocessor directives and
they begin with ''#'' symbol. Below is the list of preprocessor directives that
C language offers.
Macro :
syntax:
#define
This macro defines constant value and can be any of the basic data
types.
Macros. A macro is a fragment of code which has been given a name.
Header file inclusion
syntax:
#include <file_name>
The source code of the file ''file_name'' is included in the main
program at the specified place
A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files.
Conditional compilation
syntax:
#ifdef, #endif, #if, #else, #ifndef
Set of commands are included or excluded in source program before
compilation with respect to the condition
In computer programming, conditional compilation is compilation implementing methods which allow the compiler to produce differences in the executable produced controlled by parameters that are provided during compilation.
Other directives
syntax:
#undef, #pragma
#undef is used to undefine a defined macro variable.
#Pragma is used to call a function before and
after main function in a C program