ARMC6 忽略预处理器指令

ARMC6 ignores pre-processor directive

我正在使用 ARM Compiler v6.11 编译一些 C++。作为此代码的一部分,我有条件地包含一个使用预处理器指令的文件,如下所示。没什么不正常的。

#if BOARD == TP_EARHART_V1_0_0
    #include "LorawanTP.h"
#endif

我的问题是文件被包含在内,因此导致大量错误。我不知道为什么预处理器指令似乎只是被忽略了。

现在,我首先想到的是:"Well you're obviously re-defining the BOARD macro somewhere else and it actually equals TP_EARHART_V1_0_0"。不幸的是,情况并非如此,我已经通过以下方式验证了这一点:

#define STRING2(x) #x
#define STRING(x) STRING2(x)
#pragma message "BOARD = " STRING(BOARD)

#if BOARD ==TP_EARHART_V1_0_0
    #include "LorawanTP.h"
#endif

产生结果:

[Warning] node_flow.h@23,9: BOARD = WRIGHT_V1_0_0 [-W#pragma-messages]

我现在不太确定去哪里找。任何见解都非常赞赏。

我应该注意,我也尝试过以下方法,但无济于事:

#if defined BOARD && (BOARD == TP_EARHART_V1_0_0)

我能想到的最接近的是这样的

宏:

#define BOARD_TYPE(board) \
    ((defined( BOARD_ ## board) && (BOARD_ ## board)) ? 1 : 0)
#endif

然后在你的代码文件中:

#if BOARD_TYPE(TP_EARHART_V1_0_0)
    #include "LorawanTP.h"    
#endif

然后在你的预处理器或另一个包含文件集:

BOARD_TP_EARHART_V1_0_0 = 1