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

查看:170
本文介绍了在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 <codeanalysis\warnings.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代码分析中禁止外部标头的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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