gsl::suppress whole include statements

Viewed 1103

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

Microsoft.CppCoreCheck
Microsoft.Gsl

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

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

#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.

2 Answers

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.
Related