gpt4 book ai didi

c++ - 在 VS2017 代码分析中抑制外部 header 的警告

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:28:08 26 4
gpt4 key购买 nike

我想在 Visual Studio 2017 中使用代码分析,但我使用的是 Qt,它从标题中给了我很多警告。我试过关闭警告:

#pragma warning(push, 0)
#include <QtGlobal>
#pragma warning(pop)

但这并没有帮助。我也尝试使用 this :

#include <codeanalysis\warnings.h>
#pragma warning(push, 0)
#pragma warning(disable : ALL_CODE_ANALYSIS_WARNINGS)
#include <QtGlobal>
#pragma warning(pop)

但没有帮助。如何禁用 Qt 外部 header 的代码分析?

最佳答案

如果您打开 .vcxproj 文件,您应该在底部看到:

  <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 - 我还没有验证这个(我会在验证后更新)。

这个答案来自How can I suppress warnings for external headers in VS2017 Code Analysis?

关于c++ - 在 VS2017 代码分析中抑制外部 header 的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43755499/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com