How to correctly use "code analysis" in Visual Studio 2010 for C++? -


If I install a new copy of Windows 7 and Visual Studio 2010 Premium SP1, then a wizard-generated one Create "C ++ console applications" and add 3 headers to the .cpp file:

  #include & lt; Winsock2.h & gt; # Include & lt; WS2tcpip.h & gt; # Include & lt; Wspiapi.h & gt; By performing "Run Code Analysis", I will see warnings in Microsoft code (project is wizard-generated, hence no error):  
  1> C: \ program files (x86) \ microsoft sdks \ windows \ v7.0a \ include \ ws2tcpip.h (729): warning C6386: buffer overrun: access 'argument 1', writeable size is '1 * 4' bytes , But '42 9 4967272' bytes can be written: Lines: 703, 704, 705, 707, 713, 714, 715, 720, 721, 722, 724, 727, 728, 729 1 & gt; C: \ program files (x86) \ microsoft sdks \ windows \ v7.0a \ include \ wspiapi.h (294): warning C6386: buffer overrun: reaching 'argument 1', the writeable size is '1' bytes, But '1025' bytes can be written: Lines: 263, 264, 265, 267, 268, 270, 271, 273, 294 1 & gt; C: \ program files (x86) \ microsoft sdks \ windows \ v7.0a \ include \ wspiapi.h (236): warning C6387: '* pptResult' 0 'may be: This function specification for' WspiapiQueryDNS ' Does not follow: line: 263, 264, 265, 267, 268, 270, 271, 273, 294, 29161> C: \ Program Files (X86) \ microsoft sdks \ wind Ows \ v7.0a \ include \ Wspiapi.h (687): Warning C6387: 'Logic1' may be '0': This function does not follow the specification for 'WspiapiLegacyFreeAddrInfo': Rows: 504, 505, 506, 507, 508, 50 9 , 510, 512, 513, 514, 515, 516, 520, 528, 532, 538, 550, 551, 555, 556, 560, 563, 568, 575, 577, 578, 589, 591, 592, 593, 596, 598, 59 9, 600, 604, 607, 61 0, 611, 627, 662, 664, 680, 685, 687 1 & gt; C: \ Program Files (x86) \ microsoft sdks \ windows \ v7.0a \ Include \ wspiapi.h (481): Warning C6387: '* pptResult' may be '0': specification for this function 'WspiapiLegacyGetAddrInfo' Does not follow: Rows: 504, 505, 506, 507, 508, 509, 510, 512, 513, 514, 515, 516, 520, 528, 532, 538, 550, 551, 555, 556, 560, 563, 568, 575, 577, 578, 589, 591, 592, 593, 596, 598, 59, 600, 604, 607, 610, 611, 627, 662, 664, 680, 685, 687, 688, 691   

It uses code analysis for large projects - I get thousands of warnings in Microsoft header files and I want to get TK My own warnings can not be found, Hem: (If there is any way to exclude Microsoft Headers / SDK from code analysis, then will it be usable?

PS I know that C ++ There is not a well supported language for Visual Studio, but I can not change the language due to existing projects that I need to support and improve: (.

You can disable code analysis warnings for header files which warnings () #pragma :

  #include & lt; Codeanalysis \ warnings.h & gt; #pragma Alert (push) #pragma Alert (Disable: ALL_CODE_ANALYSIS_WARNINGS) // Header #pragma contains warnings (pop)    

Comments