我在 MSDN 或其他地方找不到任何内容,但是是否有硬编码限制 header 包含的嵌套深度?示例:
// H1.h
// guards etc.
#include "H2.h"
// H2.h
// guards etc.
#include "H3.h"
//...
// HN.h <---- how large can N get??
我想知道标准中是否有关于此的内容。如果答案是实现定义的,那么我主要对 Visual Studio 工具链感兴趣。
最佳答案
标准对此也有说明(在关于实现数量的部分,附件 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.
...
- Nesting levels for #include files [256].
请注意,这只是建议的最低限度,因此编译器可能不支持那么多包含(但大多数编译器支持,如其他答案所示)。
关于c++ - header 包含的嵌套深度是否有限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12125014/