6

I would like to try to use the Core Guidelines checker tool on a C++11/14 project, under VS2015.

In my code I use many libraries from Boost which trigger a lot of warning. I am not concerned by those warnings, since Boost is doing a lot of very clever work and the libraries were not written with the aim of conforming to the Guidelines, which they mostly predate.

But with such a flood of warnings I am unable to find out the real issues (at least according to the tool) in my code.

Is there a way to suppress all the warnings for third party code? Maybe there is some attribute before and after #including boost headers?

I have read this page from the Visual C++ Team blog but I have been unable to find it.

Francesco
  • 3,200
  • 1
  • 34
  • 46

2 Answers2

2

There's an undocumented environment variable, CAExcludePath, that filters warnings from files in that path. I usually run with %CAExcludePath% set to %Include%.

You can also use it from MSBuild, see here for an example (with mixed success): Suppress warnings for external headers in VS2017 Code Analysis

MSVC is working on something similar to GCC's system headers that should be a more comprehensive solution to this problem.

apardoe
  • 631
  • 6
  • 10
2

Currently, in VS, the feature to suppress warnings from third-party libraries are still experimental but certainly coming.

VS 2017 version 15.6 Preview 1 comes with a feature to suppress warnings from third-party libraries. In the following article, they use "external headers" as a term to refer to the headers from third-party libraries.

https://blogs.msdn.microsoft.com/vcblog/2017/12/13/broken-warnings-theory/

The above article basically says that

  • specify external headers
  • specify warning level for external headers

to suppress warnings from them. For example, if we have external headers in some_lib_dir directory and want to compile our code in my_prog.cpp which depends on the external headers, the following command should do the job.

cl.exe /experimental:external /external:I some_lib_dir /external:W0 /W4 my_prog.cpp

Note that /experimental:external is required because this is still an experimental feature, and the details of this feature may change in the future.

Anyway, we need to wait for the future release of Visual Studio.

Tomoyuki Aota
  • 867
  • 9
  • 18