preprocessor concatenation causes parse error
I came across this c code that fails to parse with the error: front-end: undefined: dv
. This is because d##dir1
should become dX
but cc replaces it with dv[0]
. This code works under gcc. Interestingly, if I replace c->dir1
with dX
it replaces d##dir1
with dX
as expected.
typedef struct {
float v[4];
} V4;
#define X v[0]
#define clip_funcdef(dir1)\
void name(V4* c) {\
float dX;\
c->dir1 = d##dir1;\
}
clip_funcdef(X)