Example 1 — Why parentheses matter
Compare an unparenthesized and a parenthesized expression macro.
#include <stdio.h>
#define BAD 1 + 2
#define GOOD (1 + 2)
int main(void) {
printf("BAD * 3 = %d\n", BAD * 3);
printf("GOOD * 3 = %d\n", GOOD * 3);
return 0;
} How It Works
BAD * 3becomes1 + 2 * 3, which is7.GOOD * 3becomes(1 + 2) * 3, which is9.- The preprocessor does textual replacement; it does not evaluate first.
