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 | /************************************************************\
* LESSON: Preprocessor just does simple text substitution *|
* substitution. The RHS could be a value or *|
* statements. *|
\************************************************************/
#include <stdio.h>
#include <stdlib.h>
#define log_int_twice(n) printf("%d\n", n); \
printf("%d\n", n);
#define fake_start() int __fake_num_counts = 0
#define fake_count() __fake_num_counts++
#define fake_end() printf("%d\n", __fake_num_counts)
void do_something() {
fake_start();
fake_count();
fake_count();
fake_count();
fake_count();
fake_end();
}
int main(int argc, const char* argv[]) {
do_something();
return EXIT_SUCCESS;
}
|
© Copyright 2019 Alexander J. Quinn This content is protected and may not be shared, uploaded, or distributed.