为什么 stdbool.h 被弃用?

Why is stdbool.h deprecated?

C standard now says:

The ability to undefine and redefine the macros bool, true, and false is an obsolescent feature and may be removed in a future version.

也就是说,stdbool.h 已弃用。但是没有给出任何理由,我也找不到。他们是打算永久添加 bool 作为基本类型还是还有其他东西?

如果您碰巧知道为什么不推荐使用它,谢谢您告诉我!

你的问题有几个误区:

  • 首先是您 link 引用了 POSIX 引用,它通常遵循 C 标准,但并非必须如此。

  • 您引用的部分 提供信息 而不是事实,因此可能根本不反映 C 标准。因此它也不具有权威性。

  • 引用还说,用户取消定义或重新定义宏的能力是可以取消的。 <stdbool.h> 头文件中的宏不会受此影响。

  • 最后,它还说了可能被带走的可能性,而不是说它将会或已经被带走。

Why is stdbool.h deprecated?

不是。

您引用了以下注释:

The ability to undefine and redefine the macros bool, true, and false is an obsolescent feature and may be removed in a future version.

这意味着以后可能会删除以下段落:

An application may undefine and then possibly redefine the macros bool, true, and false.

这并不意味着 header 或其内容将被删除。