如何在 Visual C++ 中抑制外部头文件中的警告 [英] How to suppress warnings in external headers in Visual C++
问题描述
我正在开始一个新的 BREW 项目,我想使用警告级别 4 (/W4) 进行编译,以保持应用程序代码的整洁.问题是 BREW 头文件本身不能用/W4 干净地编译.
I'm starting a new BREW project, and I'd like to compile with Warning Level 4 (/W4) to keep the application code nice and clean. The problem is that the BREW headers themselves don't compile cleanly with /W4.
在 gcc 中,您可以使用 -I 和 -isystem 来区分应用程序头和系统头,然后默认情况下 gcc 不会在系统头中报告任何编译警告.Visual C++ 中是否有等效机制?
In gcc you can differentiate between application and system headers by using -I and -isystem, and then by default gcc doesn't report any compilation warnings in system headers. Is there an equivalent mechanism in Visual C++?
推荐答案
这个问题似乎有答案.
这篇文章讨论了/external:I
可用于包含带有一组特殊警告的标头.
this post talks about /external:I
that can be used to include headers with a special set of warnings.
我自己没有测试过,但博文是 2017 年的.
I have not tested it myself, but the blog post is from 2017.
这篇关于如何在 Visual C++ 中抑制外部头文件中的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!