C++ 中的 #ifdef 1 是什么意思?

发布于 2024-11-26 23:29:31 字数 126 浏览 4 评论 0原文

在 C++ 中,我知道程序员使用 #ifdef 0 来阻止代码运行,但在同一个项目中我看到很多 #ifdef 1。这是否意味着代码始终运行?不幸的是,代码无法编译,所以我不能运行和测试!

in C++, I know that programmers use #ifdef 0 to block out code from running, but in this same project I see a lot of #ifdef 1. Does this mean that the code always runs? Unfortunately the code does not compile so I can't just run and test!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

可爱咩 2024-12-03 23:29:31

#ifdef 1 格式不正确。 #ifdef 指令需要一个标识符; 1 不是标识符。

#ifdef x 相当于#if Defined(x)。如果标识符命名了已定义的宏(即已使用 #define 定义且尚未未定义的宏,则 define 预处理运算符将生成 true通过#undef),否则为false

#if 指令启用或禁用其与相应的 #else#elif#endif< 之间的行的编译。 /code> 后面的指令(指令嵌套)。

很可能,您真正要寻找的是 #if 1 (或 #if 0),这是有效的。

#ifdef 1 is ill-formed. The #ifdef directive requires a single identifier; 1 is not an identifier.

#ifdef x is equivalent to #if defined(x). The defined preprocessing operator yields true if the identifier names a defined macro (i.e., a macro that has been defined with #define and not yet undefined via #undef) and false otherwise.

The #if directive enables or disables compilation of the lines between it and the corresponding #else, #elif, or #endif directive that follows it (the directives nest).

Chances are, what you are really looking for is #if 1 (or #if 0), which is valid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文