避免隐式预编译头依赖?
我们使用预编译头来包含 Boost 和 Windows 等库文件。
我们的 precompiled.h
明确包含在每个 .cpp
文件的顶部,以便使用预编译头命令 (/Yc
,/Yu
和 /Fp
)。我认为这是必要的。
然而最近,我发现 /FI
,它强制在源文件的顶部包含一个包含文件。我尝试使用它来强制包含 precompiled.h
而不是显式包含它,果然,它起作用了。
这将允许我们省略预编译头(就我而言,这是一个实现细节),并且仅指定文件的实际依赖项。
不幸的是,验证我们不依赖 precompiled.h
提供的隐式依赖项的唯一方法似乎是定期运行不带 /FI"precompiled.h"< 的构建。 /code> 查看哪些文件有问题。
这是相当繁重的。有更好的办法吗?
We are using a precompiled header to include library files such as Boost and Windows.
Our precompiled.h
is included explicitly at the top of each .cpp
file in order to work with the precompiled header commands (/Yc
, /Yu
, and /Fp
). I accepted that as necessary.
Recently, however, I found /FI
, which forces an include file at the top of the source file. I tried using it to force-include precompiled.h
instead of including it explicitly, and sure enough, it worked.
This would allow us to omit the precompiled header (which is an implementation detail, as far as I am concerned), and only specify the actual dependencies of the file.
Unfortunately, it looks like the only way to validate that we aren't relying on implicit dependencies provided by precompiled.h
is to periodically run through a build without /FI"precompiled.h"
to see which files have a problem.
This is fairly onerous. Is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论