locked
Static Code Analysis For Native C++ Code Not Working

    Question

  • Hello,

    I am using VS 2010 RC for enabling Static Code Analysis on our native C++ Source Code.

    Steps I Followed:

    1) GoTO Project->Config Properties->CodeAnalysis->General

         Checked "Enable CodeAnalysis for C/C++ ON Build"

    2) Since our code doesn't have any managed code, I didn't check the other two options above and below.

    3) In the Rule Set I selected "Microsoft All Rules"

    4) I checked for the Build Command Options whether /analyze is added properly or not,

    /Zi /nologo /W3 /WX- /O2 /Oi /Oy- /GL /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm- /EHsc /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Yu"StdAfx.h" /Fp"Release\CPlusSample3.pch" /Fa"Release\" /Fo"Release\"

    /Fd"Release\vc100.pdb" /Gd /analyze /errorReport:queue

    5) Now I build the code and checked for No Compilation Errors.

    6) Then Run the menu command, Analyze->Run Code Analysis on only MyCPPProject

    Then If I watch in the output window, I have

    1> Running Code Analysis...

    1> Code Analysis Complete -- 0 error(s), 0 warnings(s)

    Like wise many I intentionally made many such Errors but nothing get listed in Static Code Analysis.

    Any Suggestions how to make Static Code Analysis Work

    Sample Source Code Tried:

    int _tmain(int argc, _TCHAR* argv[])
    {
      Point2D* myPoint = new Point2D();
      myPoint->Display ();
    }

     

     

     

    Thursday, March 25, 2010 11:09 AM

Answers

  • Hello,

    Please include Warnings.h header file in CodeAnalysis folder. Please make sure the following directive is in your source code:
     #include <codeanalysis\warnings.h>

    Please have a try and let me know the result. For more information about code analysis on C/C++ code, please refer to:
    http://msdn.microsoft.com/en-us/library/ms182025(VS.80).aspx

    Best regards,


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    • Edited by Roahn Luo Friday, March 26, 2010 6:34 AM link
    • Marked as answer by Roahn Luo Tuesday, March 30, 2010 2:03 AM
    Friday, March 26, 2010 6:31 AM