Home »
C programs
C Preprocessors Programs
By IncludeHelp Last updated : March 10, 2024
In C programming language, the preprocessors are the programs that process the source code before the compilation. We can say that preprocessors are not the part of the program compilation, it's a separate process which process the code before the compilation.
C Preprocessor Directives
There are following preprocessor directives in C programming language,
Preprocessor Directives |
Description |
#define |
To define a preprocessor macro. |
#include |
To include the code from another file or to include header file in the current code. |
#undef |
To undefine a defined preprocessor macro. |
#ifdef |
To check whether a macro is defined or not, it returns true if macro is defined. |
#ifndef |
To check whether a macro is defined or not, it returns true if macro is not defined. |
#if, #else, #elif, #endif |
To control the compilation of portions of a source code. |
#error |
To print the error message on stderr. |
#pragma |
To issue special commands to the compiler, using a standardized method. |
C Preprocessors Programs (Examples)
This section contains the C solved programs on C preprocessors, practice these programs to learn the concept of C preprocessors. Each program contains the solved code, output and explanations.
List of C Preprocessors Programs
- The #if directive Example in C
- The #if ... #else directive Example in C
- The # Preprocessor Operator Example in C
- The ## Preprocessor Operator Example in C
- The __LINE__ Macro Example in C
- Print the current function name by using __func__ in C
- The #line directive Example in C
- Define Macros for YES and NO constants using #define in C
- Define a function like Macro that should use printf in C
- Define Macro PRINT to print given integer argument in C
- Define Macros to SET and CLEAR bit of a PIN in C
- Define Macro to toggle a bit of a PIN in C
- Define a Macro to set Nth bit to Zero in C
- Define a constant using Macro to use in Array declarations in C
- How to redefine a Macro in C?
- How to check whether a Macro is defined or not in C?
- Print argument (i.e. variable name, value) using Macro in C
- Print error message from any function with function name, line number in C.
- Macro Arguments Evaluation in C
- Define a Macro to find total number of elements in C
- Define a Macro to round a float value to nearest integer in C
- C program to print the function names defined in the source code
- C program to print the name of the source code file
- C program to print the line number in source code with filename and function name