I found this snippet on stackoverflow the other day (thanks for that):
#define PLATFORM 3
#define PASTER(x,y) x ## _ ## y
#define EVALUATOR(x,y) PASTER(x,y)
#define PLATFORMSPECIFIC(fun) EVALUATOR(fun, PLATFORM)
extern void PLATFORMSPECIFIC(somefunc)(char *x);
Compiled with gcc -E, it results in:
# 1 "xx.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "xx.c"
extern void somefunc_3(char *x);
However:
#define PLATFORM linux
#define PASTER(x,y) x ## _ ## y
#define EVALUATOR(x,y) PASTER(x,y)
#define PLATFORMSPECIFIC(fun) EVALUATOR(fun, PLATFORM)
extern void PLATFORMSPECIFIC(somefunc)(char *x);
results in:
# 1 "xx.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "xx.c"
extern void somefunc_1(char *x);
What can I do to make this return 'somefunc_linux' ?. Clang seems to do it right, btw.