c++ - header 包含的嵌套深度是否有限制?

标签 c++ compiler-construction limit header-files nested

我在 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/

相关文章:

mysql - 选择具有三个最大值的组

c++ - 我可以通过 C++ 中的(无符号)char* 读取任何可读的有效内存位置吗?

c++ - g++ 为什么你不必链接 iostream 二进制文件,但对于 pthread 却必须链接?

c++ - 来自 std::vector 的 pop-push 元素并重用元素

c++ - C++ 可变参数模板如何在内部工作

tree - 使用翻译方案进行 7-2+3 的后期修复表示法的可能树

mysql - 受累积列数量限制

C++ 静态构造函数返回一个容器

java - 为什么 java 编译器不显示明显除以零的警告?

php - 文档大小超过 32 MB 的 no-sql 数据库?