2021年4月2日星期五

C Pre-processing: Chaining defines together

I'm trying to concatenate multiple symbols together based on an if statement but have looked on SO and was unable to find something that worked without needing arguments passed into my last macro.

Essentially I'm trying to do this

#define COMMS_WD_PORT 1  #define COMMS_WD_TXRX CAN_TX  #if COMMS_WD_TXRX == CAN_TX      #define COMMS_WD_REG (uint32_t*)canREG#COMMS_WD_PORT##->TIOC  #else      #define COMMS_WD_REG (uint32_t*)canREG#COMMS_WD_PORT##->RIOC  

没有评论:

发表评论