Preprocessor
Macro Constants
Object-like macros name compile-time constants before the compiler sees the program.
Macro Constants
macro_constants.c
#include <stdio.h>
#define TAX_RATE 8
int main(void) {
int price = ;
int taxRate = 8;
int tax = price * taxRate / 100;
int total = price + tax;
printf("total=%d\n", total);
return 0;
}
#include <stdio.h>
#define TAX_RATE 8
int main(void) {
int price = ;
int taxRate = 8;
int tax = price * taxRate / 100;
int total = price + tax;
printf("total=%d\n", total);
return 0;
}
#include <stdio.h>
#define TAX_RATE 8
int main(void) {
int price = ;
int taxRate = 8;
int tax = price * taxRate / 100;
int total = price + tax;
printf("total=%d\n", total);
return 0;
}
object-like macro
The preprocessor replaces a macro name with its replacement text before parsing.
runtime use
The trace uses the expanded value so the replay stays aligned with source lines.