I have a set of #defines like that:
#define PORTA port_a
#define PORTB port_b
#define PORTC port_c
And some re-definitions of these into:
#define MY_PORT1 PORTA
#define MY_PORT2 PORTB
#define MY_PORT3 PORTC
And also a series of xxx_set(param1, param2)
functions where xxx
belongs to each PORTx, so:
PORTA_set(param1, param2)
PORTB_set(param1, param2)
PORTC_set(param1, param2)
I need to call these functions but using a single one, with my "custom port name" as the first parameter, so example:
set(MY_PORT1, param1, param2)
must expand to PORTA_set(param1, param2)
, and so on.
I tried after reading several similar questions, related to expansion of macros into concatenations:
#define CAT_I( x, y ) x ## y
#define CAT( x, y ) CAT_I( x, y )
#define set( port, param1, param2 ) CAT( port, _set )(param1, param2)
But this throws me error
expected ';' before '_set'
pasting ")" and "_set" does not give a valid preprocessing token
What am I missing?