Creating C macro with ## and __LINE__ (token concatenation with positioning macro)

The problem is that when you have a macro replacement, the preprocessor will only expand the macros recursively if neither the stringizing operator # nor the token-pasting operator ## are applied to it. So, you have to use some extra layers of indirection, you can use the token-pasting operator with a recursively expanded argument: #define … Read more

How can I concatenate twice with the C preprocessor and expand a macro as in “arg ## _ ## MACRO”?

Standard C Preprocessor $ cat xx.c #define VARIABLE 3 #define PASTER(x,y) x ## _ ## y #define EVALUATOR(x,y) PASTER(x,y) #define NAME(fun) EVALUATOR(fun, VARIABLE) extern void NAME(mine)(char *x); $ gcc -E xx.c # 1 “xx.c” # 1 “<built-in>” # 1 “<command-line>” # 1 “xx.c” extern void mine_3(char *x); $ Two levels of indirection In a comment … Read more