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.
#include
#define
#undef
#if, #else, #elif, #endif
#ifdef, #ifndef
Used to include header files.
< > – System header files
" " – User-defined header files
Used to define macros or symbolic constants.
Used to undefine a macro.
| Macro | Description |
|---|---|
__DATE__ | Current date |
__TIME__ | Current time |
__FILE__ | File name |
__LINE__ | Line number |
Improves code readability
Enables conditional compilation
Saves development time
Supports code reuse
Preprocessor works before compilation
Directives start with #
#include adds header files
#define creates macros
Conditional directives control compilation.
Take quizzes related to this topic and see where you stand!
Start Quiz Now