这可能是一个荒谬的问题,我对答案有 99% 的把握,但我想确定一下。
C++20 modules 不需要需要任何类型的 module 接口文件的包含保护。
C++20
modules
module
我的说法正确吗?到目前为止,我读到的关于模块的所有内容都让我相信,不需要保护,因为模块只编译一次,然后为导入该模块的每个翻译单元重用。
不需要包含守卫。模块只导入一次。
预处理器定义不会从模块中转义,因此包含守卫无论如何都不起作用。
Macros,preprocessor directives,and non-exported names declared in a module are not visible and therefore have no effect on the compilation of the translation unit that imports the module.