预编译头有助于重建吗?
我阅读了一些有关预编译头的问题,但找不到直接答案。
我通常会重建整个 Visual Studio 2010 解决方案。
我的解决方案中的项目之一是 C++/CLI 项目。
我认为在该项目中使用预编译头会提高编译速度。
经过一些实验,似乎使用预编译头只会减慢重建过程。
预编译头仅对未完全清理旧文件的构建有帮助吗?
编辑:
例如,假设我的 StdAfx.h 只有 1 行:
#include <string>
I read some of the questions about precompiled headers but couldn't find a direct answer to that.
I usually rebuild my entire Visual Studio 2010 solution.
One of the projects in my solution is a C++/CLI project.
I thought that using precompiled headers in that project will increase the speed of the compilation.
After some experiments, it seems that using precompiled headers only slows the rebuild process.
Do precompiled headers only help with builds that didn't completely clean the old files?
EDIT:
For example, let's say my StdAfx.h has only 1 line:
#include <string>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于!
对于重建,这是编译预编译标头的额外成本与不必为每个源重新解析这些标头所带来的加速之间的权衡。
如果您有许多源文件在预编译头中使用许多相同的头,您应该会看到好处。否则,您应该看到几乎没有加速,或者更糟的是,由于携带一组整体标头和拥挤的全局命名空间的开销而导致速度减慢。
It depends!
For Rebuilds, it's a trade-off between the extra cost of compiling the precompiled header and the speed-up from not having to re-parse those headers for each of your sources.
If you have many source files that use many of the same headers in your precompiled header, you should see a benefit. Otherwise, you should see almost no speed-up, or worse, a slow-down due to the overhead of carrying around a monolithic set of headers and a crowded global namespace.