C + + code static analysis tool Cppcheck

Source: Internet
Author: User

C + + code static analysis tool Cppcheck

  • Author:echo Chen (Chenbin)

  • Email:[email protected]

  • blog:blog.csdn.net/chen19870707

    date:jan.1st, 2015

    Recent games into the tail, has been on-line operation, the demand is relatively small, can have time to organize the optimization of the code, but the optimization without a standard, it is difficult to have a practical effect, so first from the simple code static analysis began to find a lot of code static check tools, Splint,pclint, purify, Infusion, Cppcheck and so on, but Cppcheck document the most streamlined, looks the most easy to use, personal simple ideas to solve complex problems, so chose Cppcheck.

    1.cppcheck Downloads

    Cppcheck now has a version of 1.68, the new version of Cppcheck needs c++11 support, here to choose the most classic version 49.

    : cppcheck-1.49.tar.bz2

    2.cppcheck Installation
       1: tar jxvf cppcheck-1.49.tar.gz
       2: CD cppcheck-1.49
       3: make
       4: make install

    If the make process reports the following error:

    You need to install the Pcre third party expression Library

    After installation, make & make install succeeded.

    3.cppcheck use

    Use Cppcheck–h to see Help, here are a few of the most useful options

       1: cppcheck.-j 3--enable=all--xml 2>result.xml

    The-J parameter specifies the number of threads to check, and the-j parameter is useful if you need to check the amount of code.
    --ENABLE Specifies the currently specified check level, optional parameters are all,style,information, etc.

    --xml is the version of the output XML

    4.cppcheck Analysis Results

    Some of the results of the project are captured as follows:

    The main point here is that these variables should be set to the const variable.

    5.cppcheck can parse the type of error

       1: automatic variable checking
       2: bounds checking of arrays
       3: class Check
       4: expired function, obsolete function call check
       5: Abnormal memory usage, release check
       6: memory leak check, mainly through memory reference pointers
       7: OS resource release check, interrupt, file descriptor, etc.
       8: exception STL function Use check
       9: code format error, and performance factor check

    -

  • Echo chen:blog.csdn.net/chen19870707

    -

  • C + + code static analysis tool Cppcheck

    Related Article

    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.