Search code examples
cgccconditional-compilation

How do I get GCC (Xtensa 5.1) to recognise definitions


For example I have this c source file (extract)

#ifdef USE_OUPUTS
#pragma message "Outputs"
static const uint8 outputMap[MAX_OUTPUT] = { RELAY_1, RELAY_2, RELAY_3, RELAY_4, LED };
static bool currentOutputs[MAX_OUTPUT];
static bool outputOverrides[MAX_OUTPUT];

uint8 ICACHE_FLASH_ATTR getOutput(uint8 idx) {
    return currentOutputs[idx];
}

void ICACHE_FLASH_ATTR setOutput(int id, int value) {
.
.
}

void ICACHE_FLASH_ATTR initOutput(void) {
.
.
}
#else
#pragma message "No Outputs"

#endif

I invoke the compiler (via a makefile) with this command:

c:/Espressif/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -v -DUSE_OUTPUTS=1 -U SLEEP_MODE -Iuser -Icommon/mqtt -Icommon/temperature -Icommon/driver -Iuser/include -Icommon/mqtt/include -Icommon/temperature/include -Icommon/driver/include  -Ic:/Espressif/ESP8266_SDK_151/include -Ic:/Espressif/ESP8266_SDK_151/include/driver -Ic:/Espressif/ESP8266_SDK_151/driver -Os -g -O2 -Wmissing-prototypes -Wpointer-arith -Wundef -Werror -Wno-implicit -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals  -D__ets__ -DICACHE_FLASH -c user/output.c -o build/user/output.o

which has the define option USE_OUTPUTS set to 1 but the compiler outputs this message from the #pragma:

    user/output.c:56:9: note: #pragma message: No Outputs
 #pragma message "No Outputs"
     ^

Can anybody please help me to see what I've done wrong?


Solution

  • #ifdef USE_OUPUTS
    

    That says OUPUTS, not OUTPUTS. You're checking the wrong macro name.