当包含不同的标头时,C 实现可以隐式包含标准标头吗?
在阅读 这是正确的 C 声明吗?如果是这样,为什么不起作用?我在想
#include <stdio.h>
int main(void) {
int bool = 0;
return bool == 0;
}
这个程序是否严格符合要求?换句话说,是允许stdio.h
包含stdbool.h
还是禁止这样做?这是规范指定的吗?
While reading Is this proper C declaration? If so, why does it not work? I was thinking about
#include <stdio.h>
int main(void) {
int bool = 0;
return bool == 0;
}
Is this program strictly conforming? In other words, is stdio.h
allowed to include stdbool.h
or is it forbidden to do so? Is this specified by the spec?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
C 标准头文件不能包含其他头文件。这与 C++ 不同,C++ 中明确允许这样做。
C99 标准,第 7.1.3 节
C standard headers can not include other headers. This is different from C++, where it is explicitly allowed.
C99 standard, section 7.1.3
我不确定它是否具有任何权威性,但这就是 Plauger说(当然这是针对 c89 的)。
我在 c99 或 c89 中找不到任何提及这一点。
编辑
我可以看到
inttypes.h
包含stdint.h
7.8-1
I'm not sure if it's authoritative in any way, but here's what Plauger says (granted it's for c89).
I can't find any mention of this in c99 or c89.
EDIT
I can see
inttypes.h
includesstdint.h
7.8-1