问题描述
我在 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).
这篇关于标头包含的嵌套深度是否有限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!