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);
But:
#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);
leads to:
# 1 "xx.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "xx.c" extern void somefunc_1(char *x);
What can I do to return this 'somefunc_linux' ?. Klang seems to be doing it right, by the way.
source share