Preprocessor
Conditional Flags
Conditional compilation includes one branch of source before the compiler runs.
Conditional Flags
conditional_flags.c
#include <stdio.h>
#define USE_BONUS 1
int main(void) {
int base = ;
#if USE_BONUS
int score = base + 3;
#else
int score = base;
#endif
printf("score=%d\n", score);
return 0;
}
#include <stdio.h>
#define USE_BONUS 1
int main(void) {
int base = ;
#if USE_BONUS
int score = base + 3;
#else
int score = base;
#endif
printf("score=%d\n", score);
return 0;
}
#include <stdio.h>
#define USE_BONUS 1
int main(void) {
int base = ;
#if USE_BONUS
int score = base + 3;
#else
int score = base;
#endif
printf("score=%d\n", score);
return 0;
}
compile-time branch
`#if` chooses source text at build time, not while the program is running.
runtime selector
The selector changes data that flows through the compiled branch.