I want to concatenate a C type name after some identifier. That's straightforward if the type name consists of just one token. However, if it's for example long int
, I'm not finding a working solution.
For example, this code:
#define ADDSUFFIX(X,Y) X ## Y
#define EVALADDSUFFIX(X,Y) ADDSUFFIX(X,Y)
#define COMBINE(X,Y) EVALADDSUFFIX(X,EVALADDSUFFIX(__,Y))
#define SIMPLETEST COMBINE(myid,long int)
#define XSTR(x) STR(x)
#define STR(x) #x
#pragma message "You get this: " XSTR(SIMPLETEST)
Provides this as output:
./testing.h:35:9: note: '#pragma message: You get this: myid__long int'
So, obviously, the whitespace is there, and I don't get a token, but a couple of tokens.
Is it possible to either remove the whitespace, or replace it with an underscore for example? (both solutions would be fine, either myid__longint
or myid__long_int
).