如何让GCC(Xtensa 5.1)识别定义

时间:2016-07-22 14:17:28

标签: c gcc conditional-compilation

例如,我有这个c源文件(提取)

#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

我使用以下命令调用编译器(通过makefile):

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

将define选项USE_OUTPUTS设置为1,但编译器从#pragma输出此消息:

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

有人可以帮我看看我做错了吗?

1 个答案:

答案 0 :(得分:0)

#ifdef USE_OUPUTS

表示OUPUTS,而非OUTPUTS。您正在检查错误的宏名称。