What are the dangers of using #pragma once? [duplicate]
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: Is #pragma once a safe include guard? 14 answers Modern C and C++ compilers support the non-standard #pragma once , preprocessor directive, which serve a similar purpose to the classic header guards: #ifndef hopefully_unique_identifier_that_doesnt_hurt_the_code #define hopefully_unique_identifier_that_doesnt_hurt_the_code // some code here #endif One problem, I'm aware of, with the classic approach is that once you've included a header, you have to #undef the header guard macro to include it again