在 VS2017 代码分析中抑制外部标头的警告 [英] Suppress warnings for external headers in VS2017 Code Analysis

查看:40
本文介绍了在 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 表示存在 CAExcludePathIncludePath 覆盖的错误,但这已在 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 代码分析中抑制外部标头的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆