The C preprocessor is a tool which filters your source code before it is compiled. |
|
The preprocessor allows constants to be named using the # notation. |
|
The preprocessor provides several other facilities which will be described here. |
|
It is particularly useful for selecting machine dependent pieces of code for different computer types, allowing a single program to be compiled and run on several different computers. |
|
The C preprocessor isn't restricted to use with C programs only. Programmers who use other languages may also find it useful, however it is tuned to recognize features of the C language like comments and strings, so its use may be restricted in other circumstances. |
|
Set of commonly used Preprocessor Directives and their Functions: |
|
#define | defines a macro substitution. | #undef | undefined a macro. | #include | specifies the files to be include. | #ifdef | tests for a macro definition | #ifndef | tests whether a macro is not defined. | #if | tests a compile-time condition. | #endif | specifies the end of #if. | #else | specifies alternatives when #if test fails. | |
|
These Preprocessor or directives can be divided into three categories: |
|
1. Macro Substitution Directives |
2. File Inclusion Directives |
3. Compiler Control Directives |
Other Recommended Posts on C programming
Post a Comment