为什么预处理器条件给我这个输出

Why is preprocessor condition giving me this output

    #include<stdio.h>
    #define Y 10
    int main()
    {
    #if X && Y || Z
    printf ("A\n");
    #else
    printf("B\n");
    #endif
    }

这里 else 是满足的 B 被打印但是如果我使用

#if !X && Y || Z

如果满足则打印A

我的问题是,如果没有定义 X 和 Z,预处理器如何解决语句?

预处理器条件中未解析的符号被视为零。因此,当既没有定义 X 也没有定义 Z 时,两者都被视为零。

参见 C11 §6.10.1 Conditional inclusion ¶4:

After all replacements due to macro expansion and the defined unary operator have been performed, all remaining identifiers (including those lexically identical to keywords) are replaced with the pp-number 0, and then each preprocessing token is converted into a token.

预处理数字(或 pp 数字)比主要语言中的数字更通用。