Hi Florijan,
I don't think you can do so since function-like macros are evaluated from outside in, as explained here: Macro Call as Macro Argument . Hence SET_BIT is evaluated first, the preprocessor sees it requires two arguments, but only one is found. It ends up with error without evaluating the inner macro (TRANSMITTER_ENABLE_BIT).
I see only two solutions:
1:
#define SET_BIT(reg,bit_no) reg |= (1<<bit_no)
#define TRANSMITTER_ENABLE_REG SCI2C2
#define TRANSMITTER_ENABLE_BIT 7
void main(void){
SET_BIT(TRANSMITTER_ENABLE_REG, TRANSMITTER_ENABLE_BIT);
}
2:
#define SET_BIT(reg,bit_no) reg |= (1<<bit_no)
#define TRANSMITTER_ENABLE SET_BIT(SCI2C2,7)
void main(void){
TRANSMITTER_ENABLE();
}