Preprocessor Directives
📘 C
👁 27 views
📅 Dec 22, 2025
⏱ Estimated reading time: 1 min
Learn #define, #include, conditional compilation.Preprocessor directives are instructions given to the compiler before the actual compilation starts.
They begin with the symbol # and do not end with a semicolon.
Common Preprocessor Directives
-
#include -
#define -
#undef -
#if,#else,#elif,#endif -
#ifdef,#ifndef
1. #include Directive
Used to include header files.
Syntax
-
< >– System header files -
" "– User-defined header files
2. #define Directive
Used to define macros or symbolic constants.
Syntax
Macro Example
3. #undef Directive
Used to undefine a macro.
4. Conditional Compilation Directives
#if, #else, #endif
#ifdef and #ifndef
Predefined Macros
| Macro | Description |
|---|---|
__DATE__ | Current date |
__TIME__ | Current time |
__FILE__ | File name |
__LINE__ | Line number |
Advantages of Preprocessor Directives
-
Improves code readability
-
Enables conditional compilation
-
Saves development time
-
Supports code reuse
Summary
-
Preprocessor works before compilation
-
Directives start with
# -
#includeadds header files -
#definecreates macros -
Conditional directives control compilation.
🔒 Some advanced sections are available for Registered Members
Register Now
Register Now
Share this Post
← Back to Tutorials