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.