Code: Select all
TARGET = XCORE-200-EXPLORER
XCC_FLAGS = -O2 -g -fxscope -save-temps -DMYTARGET=XCORE-200-EXPLORER
Code: Select all
#if (MYTARGET == STARTKIT)
#warning STARTKIT
#elif (MYTARGET == XCORE-200-EXPLORER)
#warning XCORE-200-EXPLORER
#else
#error NO TARGET?
#endif
Alternatively pass the TARGET value to MYTARGET. How do I do it? Not $TARGET at least
Update: Picking up TARGET-value "as is" makes sense for the preprocessor, but if (IS_MYTARGET == XCORE-200-EXPLORER) {myval=1;} makes little sense to the compiler (with the '-' in the names). So I probably have to make a level of indirection like below. At least this works:
Code: Select all
#define IS_MYTARGET_VOID 0
#define IS_MYTARGET_STARTKIT 1
#define IS_MYTARGET_XCORE_200_EXPLORER 2
#if (MYTARGET == STARTKIT)
#define IS_MYTARGET IS_MYTARGET_STARTKIT
#elif (MYTARGET == XCORE-200-EXPLORER)
#define IS_MYTARGET IS_MYTARGET_XCORE_200_EXPLORER
#else
#define IS_MYTARGET IS_MYTARGET_VOID
#endif