转换为无符号长宏定义会导致编译错误

时间:2018-05-14 21:53:17

标签: c casting compiler-errors macros

以下代码生成以下编译错误:

守则:

int main(void)
{
    #define a ((unsigned long) 0)
    #if a > 2
    while(1);
    #endif
}

错误:

main.c: In function 'main':
main.c:4:26: error: missing binary operator before token "long"
     #define a ((unsigned long) 0)
                          ^
main.c:5:9: note: in expansion of macro 'a'
     #if a > 2
         ^
The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.

有人可以帮助弄清楚为什么只有在'#if'语句中使用'a'宏才会发生这种情况?

0 个答案:

没有答案