1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>

#define ZERO 0

#define add_5(n)  (n + 5)
// Every time we see `add_5(▒)`, it will be expanded to `▒ + 5`.
// - This will not enforce types.  add_5("a") will be expanded to `"a" + 5`.
// - This will not follow order of operations.  add_5(10) * 3 will expand to 10 + 5 * 3.

int main(int argc, char* argv[]) {

    printf("I would like to have %d bugs in my bones.\n", ZERO);
    // Preprocessor will convert ↑ into ↓.
    printf("I would like to have %d bugs in my bones.\n", 0);
    printf("\n");

    int n1 = add_5(100);
    printf("n1 == %d\n", n1);

    int n2 = add_5(100) * 3000;
    // ⇒ 100 + 5 * 3000  ⇒  100 + (5 * 3000) not (100 + 5) * 30000
    printf("n2 == %d\n", n2);

    
    return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2023 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.