-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreproc.cpp
More file actions
35 lines (25 loc) · 798 Bytes
/
preproc.cpp
File metadata and controls
35 lines (25 loc) · 798 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
#include <bits/stdc++.h>
using namespace std;
#define VARIADIC(Param, ...) Param(__VA_ARGS__)
#define VARIADIC2(POne, PTwo, PThree, ...) POne(PThree, __VA_ARGS__, PTwo)
#define PRINT(x) printf("variable : " #x " = %d \n", variable##x)
#define debug(msg) fputs(__FILE__ ":" num2str(__LINE__) " - " msg "\n", stdout)
#define num2str(x) str(x)
#define str(x) #x
void some_func(int a, int b, int c, int d)
{
cout << a << ", " << b << ", " << c << ", " << d << endl;
}
int main()
{
VARIADIC(printf, "%d \n", 8);
// Compiler sees: printf("%d \n", 8);
VARIADIC2(some_func, 3, 8, 6, 9);
// Compiler sees: some_func(8, 6, 9, 3);
int variableY = 15;
PRINT(Y);
// compiler sees
// printf("variable : ""Y"" = %d", variableY);
debug("toto");
return 0;
}