Created: 2023-01-10 15:04
Status: #concept
Subject: Programming
Links: C Compiler Directives
Preprocessor
It is a part of the Compiler which does preliminary work before turning Source Code
.c
into Object Code .o
.
Its functions (Preprocessing, Compiling, and Linking) are often automated and is usually integrated with the compiler.
However, the commands to compile & link vary depending on the operating system.
Conditional Compilation in C
We can use the
#if
, #ifdef
, #ifndef
Directives together with a wrapping #endif
to conditionally compile code based on an Expression.Example
Using #elif
and #else
References
- C Programming, A Modern Approach, 2nd Edition, Chapter 2.1, Chapter 14
- GeeksForGeeks: C Preprocessors