Cppcheck C + + static code checking

Source: Internet
Author: User

I. Introduction to Cppcheck

Cppcheck is a static code checking tool that supports C, C + + code, and as a complement to the compiler, Cppcheck performs a rigorous logical check of the product's source code. The checks performed include:
1. Automatic variable checking
2. Bounds checking of arrays
3. Class type Check
4. Expired function, discard function call check
5. Abnormal memory usage, release check
6. Memory leak check, mainly through memory reference pointer
7. Operating system Resource release check, interrupt, file descriptor, etc.
8. Abnormal STL function Use check
9. Code format error, and performance factor check
Here are Cppcheck's introduction: Http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page

two. Install Cppcheck

The download address of Cppcheck in Linux environment is as follows: http://sourceforge.net/projects/cppcheck/files/cppcheck/1.49/cppcheck-1.49.tar.gz/ Download, the current latest version is 1.49.

Extract file: Tar xvf cppcheck-1.49.tar.gz

Compiling files: cd cppcheck-1.49 & Make

three. Cppcheck Use

Run cppcheck-h can get the parameters of the hint, here straight to introduce the parameters I used

Cppcheck-j 3--enable=all search/*

The-J parameter specifies the number of threads to check, and-j parameters are useful if you need to check for large amounts of code

--ENABLE Specifies the currently specified check level, with optional parameters such as All,style,information

Four. Summary

Cppcheck is very simple to use, can be more convenient to check out the obvious error in the code, this can be used, code good, everyone good.

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.