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
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
// Preprocessor replaces each #include line with full contents of that file

#define MAX_SIZE_BYTES 1024
// Preprocessor will replace MAX_SIZE_BYTES with 1024 everywhere below
// that statement in the file where it is written or included.

//#define TRIPLE(operand) operand*3
// TRIPLE(5) == 5*3

#define TRIPLE(operand) ((operand)*3)
// TRIPLE(5 + 3) == ((5 + 3)*3)

#define LOG_INT(expr) printf("%s == %d\n", #expr, (expr))

int main(int argc, char* argv[]) {
    int n = 5;
    printf("TRIPLE(%d) == %d\n", n, TRIPLE(n));
    
    printf("TRIPLE(%d) == %d\n", 5 + 3, TRIPLE(5 + 3));  // !!!
    LOG_INT(5 * 171717);

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

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