作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
一位同事最近声称,头文件应始终能够自行编译(例如,调用g++ someHeader.hpp
会导致someHeader.hpp.gch
正常运行)。
这句话是真的吗?
检查 header 是否能够自行编译是一种好/常见的做法吗?
如果是,这样的测试有什么好处?
在我看来,这似乎是违反直觉的,因为 header 由编译器包含在编译单元中,并且仅需在该单元的上下文中进行编译。
最佳答案
Is it a good/common practice to check if your headers are able to compile on their own?
If yes, what would be the advantage
... headers are included by the preprocessor in the compilation unit and only have to compile in the context of that unit.
关于c++ - 我的头文件是否应该能够自行编译?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60440553/
我发现以下帖子非常有帮助: How to pickle yourself? 但是,此解决方案的局限性在于,重新加载类时,它不会以其“运行时”状态返回。即它将重新加载所有变量等以及类在转储时的一般状态.
我是一名优秀的程序员,十分优秀!