2

I want to disable Code Analysis for a CPP file. There is a way to exclude header files.

https://msdn.microsoft.com/en-us/library/zyhb0b82(v=vs.100).aspx

#include <codeanalysis\warnings.h>
#pragma warning( push )
#pragma warning ( disable : ALL_CODE_ANALYSIS_WARNINGS )
    #include <third-party include files here>
#pragma warning( pop )

I want to disable for CPP file. Can some one help me, if there is a way to do this.

Thanks Santhi

4

1 回答 1

0

I know it's a very old thread - but I recently encounter an almost similar need (disable code analysis for part of the source). At least with VisualStudio-2019, the symbol CODE_ANALYSIS seems to be defined when the analysis is running.

So hopefully, you could solve your error with a simple preprocessor directive:

#ifndef CODE_ANALYSIS
#  include <third-party include files here>
#endif

I have to admit that I'm not sure if the additional /DCODE_ANALYSIS on the command line of CL comes "natively" or from one of my plugins.

于 2021-06-01T15:15:51.933 回答