The C program’s textual form is transformed into an executable file by the compiler. The C programme must go through four stages before it can be run. Pre-processing, compilation, assembly, and linking are some of them. Pre-processing include taking out the comments, expanding the macro, and expanding the inclusion files. Instructions at the assembly level are produced during the compilation phase. While the function calls are resolved in linking, the assembly level instructions are translated into machine code during the assembly phase.
A C Pre-processor: What Is It?
The compiler does not include the C Pre-processor. The C Pre-processor is merely a text replacement tool that tells the compiler to perform any necessary pre-processing prior to the compilation process. The C Pre-processor is referred to as CPP.
The block structure of the programme is unimportant; pre-processor directives like #include take effect as soon as they are noticed and continue to function until the end of the file that includes them. Pre-processing instructions in a C programme are lines that begin with the hash symbol “#.” The directive name is immediately followed by the hash symbol “#”. For instance, “#include.” ‘ The hash symbol “#” may be placed before or after whitespace.
Directive | Description |
#include | This directive will insert a particular header from another file. |
#define | This will substitute a pre-processor macro. |
#undef | Using #undef, we can undefine a pre-processor macro. |
#ifdef | It will return true if this macro is defined. |
#if | It will test if a compile time condition is true. |
#elif | Using #elif, we can define #else and #if in one statement |
#endif | It will end pre-processor conditional |
#error | Using #error, we can print the error message on stderr. |
#pragma | It will issue the special commands to the compiler, using a standardized method. |
The pre-processor, a kind of automatic editor that alters our source code before sending it to the compiler to translate into machine language code, is the first step in compiling the C programme. The pre-job processor’s includes removing all comments, which the compiler would otherwise disregard. Additionally, the pre-processor reacts to code directives like #define, #include, or #elif, which instruct the pre-processor on how to modify the source code before handing it off to the compiler.