Use of static code check tools (cppcheck)

Source: Internet
Author: User

StaticCodeCheck is to use a tool to check whether the code we write is secure, robust, and hidden.

For example, you accidentally wrote the following code:

 

[CPP] View plaincopyprint?
    1. <Span style ="Font-size: 14px ;">IntN = 10;
    2. Char* Buffer =NewChar[N];
    3. Buffer [N] = 0; </span>
 
Int n = 10; char * buffer = new char [N]; buffer [N] = 0;

This is fully compliant with the syntax, but the static code check tool will prompt that this will overflow. That is to say, it is a more rigorous compiler.

 

 

Cppcheck PC-Lint is a widely used static code check tool.

PC-Lint is the oldest and most powerful code check tool, but it is a paid software, and configuration is a little troublesome.

Cppcheck is a free open-source software. It is easy to use.

 

From http://cppcheck.sourceforge.net/Download the latest cppcheck.

After installation, you can use cppcheck-Gui to detect the code.

Refer to here (http://avitebskiy.blogspot.tw/2012/10/poor-mans-visual-studio-cppcheck.html), you can easily embed cppcheck into vs, then you can easily check a file, and support error jump.

 

    • click the Add button
    • set the title , for example cppcheck
    • set command to C: \ Program Files (x86) \ cppcheck \ cppcheck.exe
    • set arguments to -- quiet -- verbose -- template = vs $ (itempath)
    • set initial directory to $ (itemdir)
    • make sure use output window checkbox is enabled
    • click on the move up button repeatedly until your entry is at the top of the list, this will make it easier to identify you new command as you can count on it being called Tools. externalcommand1
    • click OK .

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.