这里有多个相关问题:
Why is 100 not automatically enforced?
Why would you want to include a file multiple times?
其他答案中给出了几个原因(Boost.PreProcessor、X-Macros,包括数据文件).我想添加一个特殊的"避免代码重复"的例子:OpenFOAM鼓励在函数中使用#include
个零碎代码是一个常见概念的风格.参见示例this讨论.
Ok, but why is it not the default with an opt-out?
Why has 101 not become a standardized feature yet (as it is widely supported)?