-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-macro.cpp
More file actions
48 lines (36 loc) · 745 Bytes
/
Copy pathtest-macro.cpp
File metadata and controls
48 lines (36 loc) · 745 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "macro.h"
#include <stdio.h>
#include <stdlib.h>
static int indent;
static int roulette(int a)
{
return a % 3;
}
static void say_hello(void)
{
printf("%*s => Hello from macro %zu/%zu => called %d times\n", indent, "", macro_index(), macro_count(), ++macro_local(int));
}
void macro_def(void)
{
printf("%*s => Begin\n", indent, "");
say_hello();
switch(roulette(rand()))
{
case 0:
indent += 4;
macro_call();
indent -= 4;
printf("%*s => Lucky End\n", indent, "");
return;
case 1:
indent += 2;
macro_call();
indent -= 2;
printf("%*s => Unlucky End\n", indent, "");
return;
}
indent += 3;
macro_call();
indent -= 3;
printf("%*s => Mundane End\n", indent, "");
}