I want to call a particular function according to the value i passed to the macro. But it is giving me compilation error
#include <stdio.h>
#define calling(m, j) execcall ## m(j);
void execcall0 (int x) {
printf("called 0 with arg %d\n", x);
}
void execcall1 (int x) {
printf("called 1 with arg %d\n", x);
}
void execcall2 (int x) {
printf("called 2 with arg %d\n", x);
}
int main () {
int i = 0;
for (i = 0; i < 3; i++) {
calling(i, 1);
}
}
Compilation error:
In function `main':
new.c:(.text+0x7a): undefined reference to `execcalli'
collect2: ld returned 1 exit status
Is it even possible whatever i am trying?