如何从 Visual Studio 静态代码分析中排除库标头? [英] How do I exclude library headers from my Visual Studio static code analysis?

查看:44
本文介绍了如何从 Visual Studio 静态代码分析中排除库标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了 buildbot 来使用/analyze 标志编译我的 Qt/C++ 应用程序.

I have setup buildbot to compile my Qt/C++ application with the /analyze flag.

然而,分析也在深入研究我不关心的 qt 标头:

However the analysis is also delving into the qt headers which I don't care about:

c:\qt\qt-everywhere-opensource-src-4.8.1\src\corelib\tools\qvector.h(547) : warning C6011: Dereferencing NULL pointer 'x.p': Lines: 474, 475, 476, 477, 478, 480, 491, 493, 497, 498, 499, 500, 503, 504, 518, 519, 520, 521, 522, 525, 545, 547

排除这些文件的最佳方法是什么?

Whats the best way to exclude these files en mass?

(请注意,我没有使用 IDE,我正在寻找命令行、开关或代码更改)

(Please note I am not using the IDE, I am looking for a command line, switch or code change)

推荐答案

您可以在代码中使用 #pragma warning 禁用特定代码块的所有代码分析警告.MSDN 提供了以下示例:

You can disable all code analysis warnings for a particular block of code using #pragma warning in your code. MSDN provides the following example:

#include <codeanalysis\warnings.h>
#pragma warning( push )
#pragma warning ( disable : ALL_CODE_ANALYSIS_WARNINGS )
#include <third-party include files here>
#pragma warning( pop )

(请参阅 "如何:启用和禁用特定 C/C++ 警告的代码分析" 了解更多信息.)

(See "How to: Enable and Disable Code Analysis for Specific C/C++ Warnings" for more information.)

据我所知,仅使用命令行选项无法禁用来自特定头文件的警告.

To the best of my knowledge, there is no way to disable warnings from particular header files using only command line options.

这篇关于如何从 Visual Studio 静态代码分析中排除库标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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