I'm coding for a ARM with GCC and need to concatenate (##) a name with the a definition, like this:
#define LCD_E_PORT GPIOC
...
#define RCC_PORT(x) (RCC_APB2Periph_ ## (x)) // ???
...
so that afterRCC_PORT(LCD_E_PORT) I would get RCC_APB2Periph_GPIOC. It is important to say, that the LCD_E_PORT and the RCC_APB2Periph_GPIOC are NOT strings but some low-level system defined pointers (accessing them processor's memory map).
The point of all this is to have one macro, which handles multiple port definitions.
Is there a solution for this?


I'm using arm-none-eabi-gcc.
#define RCC_PORT(x) RCC_APB2Periph_##x?RCC_PORT(LCD_E_PORT)will result inRCC_APB2Periph_LCD_E_PORTso it is wrong. I've also tried double definition, I mean:#define RCC_PORT1(x) RCC_PORT(x)but afterRCC_PORT1(LCD_E_PORT)I get an error thatRCC_APB2_Periph_ and "(" don't give a valid tokenbecause, like I said, the GPIOx is a(u32 *) ptr. It is that or it doesn't expand macros, or it expands macros to the final definition... All what I need is the definition in the middle.