如何强制 Visual Studio 2008 警告缺少头文件

发布于 2024-09-27 20:30:15 字数 172 浏览 1 评论 0原文

我是一个 C++ 应用程序的 Mac 编码员,我与使用 VS2008 的 PC 编码员共享该应用程序。当他们对需要非包含头文件的源文件进行更改时,他们不会收到警告,因为大多数头文件都位于预编译头文件中。他们可以使用什么设置来警告他们未能添加所需的包含内容?

会让我的生活更轻松,因为 GCC 要求包含内容实际存在。

I work as the Mac coder on a c++ application which I share with PC coders who use VS2008. When they make changes to a source file that requires an non-included header file they get no warnings, as most of their headers are in a precompiled header. What setting can they use to have them be warned that they failed to add the required include?

Would make my life easier as GCC requires the includes be actually present.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝礼 2024-10-04 20:30:15

呃......你所说的问题是基于一个不正确的前提。

VS 编译器中的所有标头都需要包含在内。没有办法解决这个问题。

预编译头功能不会以任何方式影响这个一般原则。唯一的区别是,在计划使用预编译标头的项目中,标头通常是通过特殊的中间头文件间接包含的。然而,无论项目是否使用预编译头,您都不能忘记包含一些头文件。在所有情况下,所有标头都必须直接或间接包含。

使用预编译头的项目将在任何对任何预编译头一无所知的编译器上完美地编译。

所以,你所描述的情况在实际中根本不可能发生。如果确实如此,那么您一定遗漏了有关该问题的一些重要细节。

Er... Your question as stated is based on an incorrect premise.

All headers in VS compiler are required to be included. There's no way around it.

Precompiled headers feature does not affect this general principle it any way. The only difference is that in projects that plan to use precompiled headers the headers are normally included indirectly, through a special intermediate header file. Nevertheless, you can't just forget to include some header file, regardless of whether the project is using precompiled headers or not. All headers must be included in all cases, directly or indirectly.

A project that's using precompiled headers will compile perfectly fine on any compiler that knows nothing about any precompiled headers at all.

So, the situation you describe simply cannot happen in practice. If it does, they you must be leaving out some important detail about the problem.

莫相离 2024-10-04 20:30:15

我将使预编译标头以仅存在于 PC 代码中的定义为条件,对于 Mac 代码反之亦然。

I would make the precompiled headers conditional on a define that is only present on the PC code, or vice versa for the mac code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文