Suppress warnings for external headers in VS2017 Code Analysis(在 VS2017 代码分析中抑制外部标头的警告)
问题描述
我想在 Visual Studio 2017 中使用代码分析,但我使用的是 Qt,它给了我很多来自标题的警告.我试过关闭警告:
I want to use the Code Analysis in Visual Studio 2017 but I'm using Qt and it gives me a lot of warnings from the headers. I've tried turning off warnings:
#pragma warning(push, 0)
#include <QtGlobal>
#pragma warning(pop)
但这无济于事.我还尝试使用 这个:
but it doesn't help. I also tried using this:
#include <codeanalysiswarnings.h>
#pragma warning(push, 0)
#pragma warning(disable : ALL_CODE_ANALYSIS_WARNINGS)
#include <QtGlobal>
#pragma warning(pop)
但没有帮助.如何禁用 Qt 外部头文件的代码分析?
but no help. How can I disable the Code Analysis for the Qt external headers?
推荐答案
如果你打开你的 .vcxproj 文件,你应该在底部看到:
If you open your .vcxproj file, down the bottom you should see:
<Import Project="$(VCTargetsPath)Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
您可以在下面添加:
<PropertyGroup Condition="'$(Language)'=='C++'">
<IncludePath>$(QTDIR)include;.GeneratedFiles;$(IncludePath)</IncludePath>
<CAExcludePath>$(QTDIR)include;.GeneratedFiles;$(CAExcludePath)</CAExcludePath>
</PropertyGroup>
Microsoft 表示存在 CAExcludePath
被 IncludePath
覆盖的错误,但这已在 Visual Studio 2017 V15.3 并且你只需要设置 CAExcludePath
- 我还没有验证这个(我会在我更新这个做).
Microsoft say there's a bug where CAExcludePath
is overwritten by IncludePath
but this is fixed in Visual Studio 2017 V15.3 and you'll only need to set CAExcludePath
- I haven't verified this (I'll update this once I do).
这个答案来自 如何在 VS2017 代码分析中抑制外部标头的警告?
这篇关于在 VS2017 代码分析中抑制外部标头的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 VS2017 代码分析中抑制外部标头的警告


- C++ 协变模板 2021-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- Stroustrup 的 Simple_window.h 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 从python回调到c++的选项 2022-11-16
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 静态初始化顺序失败 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01