gpt4 book ai didi

c - #ifdef 需要查询和说明

转载 作者:太空狗 更新时间:2023-10-29 15:02:48 24 4
gpt4 key购买 nike

我看到这样的结构:

#ifdef FOO || defined BAR
...
#endif

和编译器的提示“警告:#ifdef 指令末尾的额外标记”,显然应该是:

#if defined FOO || defined BAR
...
#endif

标准有明确规定吗?你能指出相关部分吗?

最佳答案

在 C99 中,6.10 预处理指令,第 1 段是语法:

if-group:
# if constant-expression new-line groupopt
# ifdef identifier new-line groupopt
# ifndef identifier new-line groupopt

这表明您使用 #ifdef 的第一个构造是不正确的,因为只有标识符可以跟在 #ifdef 之后,不允许使用常量表达式。

关于c - #ifdef 需要查询和说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9314832/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com