在Linux上使用Cmake时,我该如何告诉PVS-Studio忽略第三方库中的所有文件
How can I tell PVS-Studio to ignore all of the files in a third party library when using CMake on Linux
我正在使用Linux上的cmake使用PVS-Studio。我最近在我的项目中添加了第三方库。
PVS-Studio正在为第三方库的标题文件中标记可能的问题。在分析我的代码时,我该如何告诉PVS-Studio忽略整个第三方库?当在Windows上使用PVS-Studio与Visual Studio一起使用时,我可以使用Visual Studio内的PVS-Studio扩展来执行此操作。在Linux上我没有。
我已经将我的cmakelists.txt文件附加到了此项目(非常简单(,加上PVS-Studio发出的警告列表。
cmakelists.txt
cmake_minimum_required(VERSION 3.15.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
project(my_project)
include_directories($ENV{HOME}/code/repo/other/GSL/include)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(proj_srcs main.cpp notes.txt)
add_executable(${PROJECT_NAME} ${proj_srcs})
include($ENV{HOME}/code/repo/other/pvs-studio-cmake-examples/PVS-Studio.cmake)
pvs_studio_add_target(TARGET ALL COMPILE_COMMANDS OUTPUT FORMAT errorfile)
警告
.../other/GSL/include/gsl/multi_span:663:1: warning: V547 Expression is always true.
.../other/GSL/include/gsl/multi_span:1163:1: warning: V560 A part of conditional expression is always true: totalSize <= (9223372036854775807L).
.../other/GSL/include/gsl/string_span:118:1: warning: V547 Expression 'cur != nullptr' is always true.
我仍然很难让它起作用。
在cmakelists.txt中我有:
# The header files for the C++ Standard Library are located in /usr/include.
# Unfortunately ARGS --exclude-path /usr/include does not suppress the warnings
# generated by Clang.
pvs_studio_add_target(TARGET ALL COMPILE_COMMANDS OUTPUT FORMAT errorfile ARGS --exclude-path /usr/include)
用叮当声构建12.0.0 x86_64-pc-linux-gnu pvs studio会产生数百条警告。例如,
--- snip ---
/include/c++/10/bits/stl_numeric.h:64:1: warning: V1061 Extending the 'std' namespace may result in undefined behavior.
/include/c++/10/numeric:80:1: warning: V1061 Extending the 'std' namespace may result in undefined behavior.
/include/c++/10/numeric:167:1: warning: V1061 Extending the 'std' namespace may result in undefined behavior.
/include/c++/10/numeric:226:1: warning: V1061 Extending the 'std' namespace may result in undefined behavior.
/include/c++/10/pstl/glue_numeric_defs.h:15:1: warning: V1061 Extending the 'std' namespace may result in undefined behavior.
--- snip ---
有人知道可能是什么问题吗?
谢谢,
您可以使用此参数:
-e [DIR], --exclude-path [DIR]
Directory whose files are not necessary to check
cmakelists.txt:
pvs_studio_add_target(TARGET ALL
COMPILE_COMMANDS
OUTPUT FORMAT errorfile
ARGS -e /path/to/third/party -e /path/to/tests)
相关文章:
- Visual Studio 2015:Extern "C" 和 "export" 关键字
- 将数组作为参数传递给函数安全吗?作为第三方职能部门,可以探索他们想要的之外的其他元素
- 第三方 API 中的编译错误 - Visual Studio
- CMake:Android Studio 原生活动项目无法在项目根目录之外找到第三方库
- 如何调试visual studio 2017生成的C++代码.android中的SO文件和其他第三方库
- PVS-Studio抱怨浮点比较
- 在Linux上使用Cmake时,我该如何告诉PVS-Studio忽略第三方库中的所有文件
- 如何将第三方库无缝集成到Visual Studio 2017中?
- 在Visual Studio 2019中构建简单的点云可视化代码时,来自PCL的第三方库的多个错误
- PVS-Studio 是否了解远期申报的必要性?
- 带有Visual Studio的第三方图书馆
- 如何在Visual Studio代码中使用第三方DLL
- 在PVS Studio中的BOOST_REQIRE之后,将变量标记为非NULL
- PVS Studio抱怨危险的宏观表达
- 误报警告PVS Studio:V808类型的对象是创建但未使用的
- 如何在visual studio 2010中添加和使用第三方.dll,当没有提供.lib时
- 如何在Visual Studio 2015中添加第三方库
- 在Visual Studio 2013中使用第三方库
- Visual studio 2010 - c++链接第三方头文件和源代码
- 在Visual Studio 2015中进行跨平台构建时链接第三方库