我设置了 buildbot 以使用/analyze 标志编译我的 Qt/C++ 应用程序。
然而,分析也在深入研究我不关心的 qt 头文件:
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
批量排除这些文件的最佳方法是什么?
(请注意我没有使用 IDE,我正在寻找命令行、开关或代码更改)
最佳答案
您可以在代码中使用 #pragma warning
禁用特定代码块的所有代码分析警告。 MSDN 提供了以下示例:
#include <codeanalysis\warnings.h>
#pragma warning( push )
#pragma warning ( disable : ALL_CODE_ANALYSIS_WARNINGS )
#include <third-party include files here>
#pragma warning( pop )
(有关详细信息,请参阅 "How to: Enable and Disable Code Analysis for Specific C/C++ Warnings"。)
据我所知,仅使用命令行选项无法禁用来自特定头文件的警告。
关于c++ - 如何从我的 Visual Studio 静态代码分析中排除库 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10191479/