本文介绍了gsl ::抑制整个包含语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将准则支持库检查器"集成到我的项目中.

I am integrating Guideline Support Library Checkers into a project of mine.

Microsoft.CppCoreCheck
Microsoft.Gsl

当我运行它时,我从包括标准库,glm,boost等在内的库中得到了很多错误.

When I run it I get a bunch of errors from included libraries like standard libraries, glm, boost, etc.

一个具体的例子是SDL.h,我在sdl_stdinc.h中得到警告.我确保仅通过我控制下的一个标头包含SDL:

One concrete example is SDL.h where I get warnings in sdl_stdinc.h.I made sure that I include SDL only via one header under my control:

ExtSDL.hpp

ExtSDL.hpp

#pragma once
#pragma warning(disable: 4710)
#pragma warning(push, 0)
#include <SDL.h>
#pragma warning(pop)

我找不到有关如何从静态代码分析中排除此库的信息.

I can not find information on how to exclude this library from the static code analysis.

推荐答案

抑制CppCoreCheck警告的方法有多种:

There are multiple ways to suppress CppCoreCheck warnings:

  • you can suppress CppCoreChecks either using[[gsl::suppress(chapter)]] attribute, where chapter comes from C++Core Guidelines, for example, con.4. Please also look at MS docs for information.
  • you can use #pragma warning to suppress warnings individually or in bulk, as mentioend above.
  • you can suppress all warnings for "not your code" using CAExcludePath.

这篇关于gsl ::抑制整个包含语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 09:45