2021-01-20 03:28 AM
#define EXICOM_2KW 1
#define EXICOM_1KWH 0
#if EXICOM_2KW
#define EXICOM_RX_MAX_SIZE 60
#define EXICOM_TX_MAX_SIZE 18
#define EXICOM_RX_INDEX_MAX 60
#define EXI_ACTIVE 0
#elif EXICOM_1KWH
#define EXICOM_RX_MAX_SIZE 12
#define EXICOM_TX_MAX_SIZE 12
#define EXICOM_RX_INDEX_MAX 12
#endif
extern char EXICOM_Tx_Buffer[EXICOM_TX_MAX_SIZE];
extern uint8_t EXICOM_Rx_Buffer[EXICOM_RX_MAX_SIZE];
When EXICOM_2KW is 1, "EXICOM_RX_MAX_SIZE", "EXICOM_TX_MAX_SIZE", "EXICOM_RX_INDEX_MAX" are not taking their respective values(60,10,60).
I am getting a warning like subscript out of range for EXICOM_Rx_Buffer.
I am not sure whether we can use compiler switch for an array declaration.
Kindly help!!
2021-01-20 07:24 AM
Doesn't the IAR documentation tell you how to do this? If not, contact IAR support - that's what you're paying the licence fee for!
"I am getting a warning like (sic) subscript out of range for EXICOM_Rx_Buffer"
What do you mean, "like" ?
Copy & paste the complete message that you're getting.
When having preprocessor problems like this, you should examine the preprocessor output to see what the compiler is actually seeing - again, the IAR documentation should tell you how to do that, or contact IAR support.
You've shown 'extern' declarations - do these match the definitions?
"I am not sure whether we can use compiler switch for an array declaration"
It's just a preprocessor symbol - it's exactly as if it had been defined in the source code using #define