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
| #define format2(x,y) _Generic((x), \
char: _Generic((y), \
char:"%c - %c\n", \ char*:"%c - %s\n", \
int:"%c - %d\n", \
default:"error\n" \
), \
char*: _Generic((y), \
char:"%s - %c\n", \
char*:"%s - %s\n", \
int:"%s - %d\n", \
default:"error\n" \
), \
int: _Generic((y), \
char:"%d - %c\n", \
char*:"%d - %s\n", \
int:"%d - %d\n", \
default:"error\n" \
), \
default:"error\n" \
)
#define print2(x, y) printf(format2(x,y),x,y)
int main(int argc, char **argv)
{
printf("test 2 parameters\n");
print2(3, 'c');
return 0;
}
|