Is there anyway to token paste a parameter or non-function macro at the BEGINNING of the macro definition? In other words, just as if something like #define JOIN_TOKENS(a, b) ##a##b
were allowed.
An example would be JOIN_TOKENS(Up, Here)
turning into UpHere
. Also, I'd like for any values passed as parameters to not be expanded. This almost did it, but it produces an error:
#define APPEND_TOKEN(a, b) a##b
#define VAR 0
#define JOIN(a, b) APPEND_TOKEN(##a, ##b)
JOIN(VAR, iable)
It was supposed to produce VARiable
, and it did, but there were accompanying errors:
<stdin>:4:1: error: pasting formed '(VAR', an invalid preprocessing token
JOIN(VAR, iable)
^
<stdin>:3:33: note: expanded from macro 'JOIN'
#define JOIN(a, b) APPEND_TOKEN(##a, ##b)
^
<stdin>:4:1: error: pasting formed ',iable', an invalid preprocessing token
<stdin>:3:38: note: expanded from macro 'JOIN'
#define JOIN(a, b) APPEND_TOKEN(##a, ##b)
^
/
VARiable
2 errors generated.