@Christian-Ehrlicher said:
msvc doesn't know the concept of 'system headers'.
It does. It just calls them "external headers", which is IMO a better name for it, as there is nothing system about Qt on Windows for example.
@Taytoo
If you want to skip all compilation warnings from, say C:\Qt\Qt5.12.2, you can do it like this:
/experimental:external /external:W0 /external:I C:\Qt\Qt5.12.2
The first switch enables this feature (it's experimental). The second one sets the warning level for external headers (W0 disables them entirely) and the third one sets a path to treat as external.
But that's really not the problem. The question was about the static code analysis tool and those switches unfortunately won't work with that. VS static analysis tool does not have warning levels so there's no switches to configure it.
The current solution MS suggest for that is something like this:
#include <codeanalysis\warnings.h>
#pragma warning( push )
#pragma warning ( disable : ALL_CODE_ANALYSIS_WARNINGS )
#include <Qt includes you use>
#pragma warning( pop )
which, admittedly, is quite ugly and invasive. It also has a nasty side effect of silencing everything that gets included transitively from Qt, so make sure Qt headers are last on your include list.
UPDATE: There have been improvements to this and now external code can be excluded also from code analysis. See this blog post for details: Customized Warning Levels and Code Analysis for External Headers