Microsoft’s Visual Studio has provided a C++ static code analyser. It is available at navigation menu – Analyzer – Config/Run Code Analyser.
Configure the Static Code Analyser Rules
By default, the ruleset for static code analyser (C++) is ‘Microsoft Native Recommended Rules’ but you can always try different rulesets to see if it gives you more analysis (different levels of details).
Run the Static Code Analyser
You can manually run the static code analyser on projects/solutions by go to navigation menu – analyser – Run Code Analyser, also you can enable it at each build:
Sample Analysis Results
The following gives a detailed analysis on the sample code.
However, sometimes the static code analyser does not thoroughly understand the code, instead, it just warns you for potential coding pitfalls e.g. array out of bound access. In the above example, the length of the array is never one and the variable t is gaureente to be smaller than the variable maxlen. Therefore, the warning is not 100% correct but it at least hints you to review your code.
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: Cloudflare Offers Dedicated SSL Certificates
Next Post: How to Get Minimum Moves to Equal Array Elements?
In this article I would like to set aside a special group of project checks that is related to Microsoft company. I believe that the Microsoft development process is of high level and their code has low density of errors. However, even highly qualified specialists are not immune from making mistakes. So I am really glad to show what PVS-Studio is capable of.
Our articles are sometimes viewed as indirect comparison with FxCop analyzer and the diagnostics built in Visual Studio. Since PVS-Studio finds bugs after the checks of these tools, it’s worth embedding in your development process.
So, I suggest taking a look at the articles, showing the abilities of PVS-Studio by the examples of projects written in C++ and C#.
Link: http://www.viva64.com/en/b/0398/
OK. thanks