I'm facing difficulties to make the following conditional compilation working:
enum { MIDI_USB_DEV_MCU_IDX, MIDI_WC_BLE_IDX, MIDI_CONN_1_IDX, MIDI_CONN_2_IDX,MIDI_IN_OUT_UARTS_NB
};
#define MIDI_UART_IDX_TO_USE_SYSEXS MIDI_WC_BLE_IDX
I use the following code to remind me the above define should not be used in Release mode, but the compiler does not warn on the below test.
#if MIDI_UART_IDX_TO_USE_SYSEXS != MIDI_USB_DEV_MCU_IDX
#warning MIDI_UART_IDX_TO_USE_SYSEXS must be MIDI_USB_DEV_MCU_IDX in RELEASE MODE
#endif
From what I read the enums are treated as Int, using the enum in my source works fine but the conditional compiler test fails. Any help or tip would be appreciated Thanks.
Enumeration constants do not exist in precompilation phase. Your condition expression will expand to
Only way is to make constant work in
#ifexpressions is to define macro constant.If you are okay with compilation failing on error, then you can use enumeration constants with static assertion: