C + + code detection Tool

Source: Internet
Author: User
Tags ord

Cppcheck is a static code-checking tool that can check for code errors such as memory leaks, and is simple to use, which provides GUI interface operations and can be used in conjunction with the VS development tool.

1. Installation

A free install version is typically provided, and the Cppcheck.exe directory is added to the environment variable after installation, so that CMD can be used to detect code directly using the Cppcheck directive.

2, Cppcheck inspection information

Error: Errors in the code, including memory leaks, etc.;
Warning: Programming improvement advice provided to avoid bugs;
Style: Coding style, which prompts you which functions are not used, which are superfluous code, etc.;
Portability: Tips that are prone to cross-platform issues;
Performance: This part of the code can be optimized;
Information: Other information, can be ignored;

3. Use under the console

Open cmd, enter Cppcheck return will list its supported parameters, select parameters for code check:

cppcheck --enable=all  <dir> 
    • 1

This instruction lists the check information for all the files in Dir, and to export the check information, refer to the following directives:

cppcheck --enable=all <dir> > D:\detect.txt;
    • 1

–enable= has a number of parameter options, detailed reference to the Cppckeck parameter description, and the recommendation to use all according to the Cppcheck help, which is useful when scanning all files for the entire project, as it can check for unused functions.

4. Use alone

Cppcheck provides the operation interface, such as, click on the left C + + button, select the directory, you can automatically detect all the files in the folder, by default, will give you a list of all the detection information supported by Cppcheck, a total of six items, click on the right side of the image to select the content to display.

5. Use with VS

Embed Cppcheck into vs as an external tool so that static code errors can be checked directly during the program development phase.
Configuration:
Click on Tools with VS, select External tool options, add tools,
Title: Cppcheck The name under the VS tool;
Command: Select Cppcheck.exe, including absolute path;
Parameters: According to the parameters of Cppcheck, you can use the following
–quiet–platform=win64(PROJec td ir ) ;–ena< Span id= "mathjax-span-22" class= "Mi" >bl e= All (ProjectDir); –enable=all (ProjectDir);
(PROJECTDIR);ItsInTheOneAOnlyExplicitlyShownProsecutionCheckToOfWrongMissLetterInterest,ItsMore thanTwoAProsecutionCheckTheYesLetter ; beginning start eye record : (ProjectDir); where the first one shows only the error messages that are checked, the remaining two check all information; initial directory: (ITEMDIR) or $ (ProjectDir)
Itemdir refers to a separate file, and if you select Itemdir in the parameter, only the currently selected file is checked;


You can add the Cppcheck tool to vs by checking the close on exit and clicking OK after using the Output window.

Use:
Click on the tool, find the Cppcheck option, click on the Output window to export the check information, you can get the error file and the number of rows.

C + + code detection Tool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.