Are there limits to how deep nesting of header inclusion can go?(标头包含的嵌套深度是否有限制?)
问题描述
我在 MSDN 或其他地方找不到任何内容,但是是否有硬编码限制标头包含的嵌套深度?示例:
I can't find anything on MSDN or elsewhere, but are there hard-coded limits to how deep nesting of header inclusion can go? Example:
// H1.h
// guards etc.
#include "H2.h"
// H2.h
// guards etc.
#include "H3.h"
//...
// HN.h <---- how large can N get??
我想知道标准中是否有关于此的任何内容.如果答案是实现定义,那么我主要对 Visual Studio 工具链感兴趣.
I wonder if there is anything in the Standard about this. If the answer is implementation defined, then I'm primarily interested in the Visual Studio toolchain.
推荐答案
标准也有说明(在关于实现数量的部分,附件 B):
The standard also says something about it (in the part about implementation quantities, annex B):
限制可能会限制数量,包括以下描述的数量或其他.建议在每个数量后面加上括号内的数字作为该数量的最小值.然而,这些数量只是指导方针,而不是确定合规性.
The limits may constrain quantities that include those described below or others. The bracketed number following each quantity is recommended as the minimum for that quantity. However, these quantities are only guidelines and do not determine compliance.
...
- #include 文件的嵌套级别 [256].
请注意,这只是推荐的最小值,因此编译器可能不支持那么多包含(但大多数编译器都支持,如其他答案所示).
Note that this is only a recommended minimum, so a compiler may not support that many inclusions (but most compilers do, as shown in other answers).
这篇关于标头包含的嵌套深度是否有限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:标头包含的嵌套深度是否有限制?
基础教程推荐
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- CString 到 char* 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
