c - 预处理器#ifndef

标签 c header-files ifndef

假设我有a.h其中包括以下内容:

<stdbool.h>
<stddef.h>
<stdin.h>

假设我还有b.h其中还包括<stdbool.h> 。如果a.h#ifndef其中的预处理器定义语句和 b.h没有。会a.h仅包含 b.h 中未包含的内容?那么当 b.h包括a.h ,将 a.h包括stddef.hstein.h并且不重新包含stdbool.h或者那些预处理器定义函数仅用于查看整个类是否被重新定义,而不是其中的特定函数?

编辑:

此外,假设 b.h包含另一个头文件,其中包含 stdbool.h -这使得b.hstdbool.h都来自该类(class)和 a.h 。这会导致错误吗?

最佳答案

所有 C 标准头文件都必须能够以任意顺序多次包含:

Standard headers may be included in any order; each may be included more than once in a given scope, with no effect different from being included only once

关于c - 预处理器#ifndef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9690212/

相关文章:

c++ - 静态库的链接器错误

c++ - 可以在函数名上使用#ifndef 吗?

swift - Swift 中有条件地排除代码

c - WDK : get processId by name. 可执行文件

c++ - std::ostream 无需定义 header 即可识别

c - 如何在使用 getch() 读取时删除读取的字符

c++ - XCode 4 搜索中的相对#include 路径?

c - 字符串操作C编程

c++ - 我怎么知道数组中元素的数量