Suppression of warnings for external headers in VS2017 Code Analysis

I want to use Code Analysis in Visual Studio 2017, but I am using Qt, and this gives me a lot of warnings from the headers. I tried disabling warnings:

#pragma warning(push, 0) #include <QtGlobal> #pragma warning(pop) 

but it doesn’t help. I also tried using this :

 #include <codeanalysis\warnings.h> #pragma warning(push, 0) #pragma warning(disable : ALL_CODE_ANALYSIS_WARNINGS) #include <QtGlobal> #pragma warning(pop) 

but no help. How to disable code analysis for external Qt headers?

+1
source share
1 answer

If you open the .vcxproj file, you will see below:

  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> 

below this you can add:

  <PropertyGroup Condition="'$(Language)'=='C++'"> <IncludePath>$(QTDIR)\include;.\GeneratedFiles;$(IncludePath)</IncludePath> <CAExcludePath>$(QTDIR)\include;.\GeneratedFiles;$(CAExcludePath)</CAExcludePath> </PropertyGroup> 

Microsoft says that there is an error in which CAExcludePath overwritten by IncludePath , but this is fixed in Visual Studio 2017 V15.3 and you only need to install CAExcludePath - I have not checked it yet (I will update it when I do this).

This answer came from How can I suppress warnings for external headers in VS2017 code analysis?

+2
source

Source: https://habr.com/ru/post/1271038/


All Articles