I'm trying to recreate this line via the preprocessor
#pragma location = ADDR + OFFSET
Currently, i'm pretty close by using this (C Preprocessor, Stringify the result of a macro):
#define QUOTE(str) #str
#define EXPAND_AND_QUOTE(str) QUOTE(str)
#define TEST(X) location = ## X ## + OFFSET
#define TESTE(X) EXPAND_AND_QUOTE(TEST(X))
_Pragma(TESTE(ADDR));
Which works if i remove the = and + sign from
#define TEST(x) location = ## X ## + OFFSET
Unfortunately, adding the = or + sign provides me with these errors:
test.c:3:27: error: pasting "=" and "ADDR" does not give a valid preprocessing token
#define TEST(X) location = ## X ## + OFFSET
^
test.c:4:35: note: in expansion of macro ‘TEST’
#define TESTE(X) EXPAND_AND_QUOTE(TEST(X))
^~~~
test.c:6:9: note: in expansion of macro ‘TESTE’
_Pragma(TESTE(ADDR));
^~~~~
test.c:6:15: error: pasting "ADDR" and "+" does not give a valid preprocessing token
_Pragma(TESTE(ADDR));
^
test.c:3:33: note: in definition of macro ‘TEST’
#define TEST(X) location = ## X ## + OFFSET
^
test.c:6:9: note: in expansion of macro ‘TESTE’
_Pragma(TESTE(ADDR));
^~~~~
Any ideas? Thanks!