First download the Linux version from here: http://sourceforge.net/projects/cppcheck/files/cppcheck/
then download the corresponding version, unzip, then install:
Compile:
g++-o cppcheck-ilib cli/*.cpp lib/*.cpp
Installation:
Make install
Cppcheck default installation will error as follows:
Cppcheck:unusedfunction check can ' t be used with '-j ' option. disabling unusedfunction check.
(information) Failed to load STD.CFG. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled without cfgdir set. Either the STD.CFG should is available in CFG or the Cfgdir should is configured.
So instead of using their make, I directly compile with the g++ parameter: g++-o cppcheck-ilib cli/*.cpp lib/*.cpp
And then it's checked.
Cppcheck-j 3--enable=all src/
- Enable to check the rules:
- Default:--enable=error
- --enable=all
- --enable=unusedfuntion Path
- --enable=style
- Rule definition:
- Error: Errors that occurred
- Warning: Recommended information for preventing bug-defensive programming
- Style: Coding format problem (no functions used, extra code, etc.)
- Portablity: Portability warning. Compatibility issues may occur if this section is ported to another platform
- Performance: It is recommended to optimize the performance of this part of the code
- Information: Some interesting information that you can ignore without looking at.
- Save results to file: redirect >
- -j 3 uses 3 threads, if the code works too large, you can use 15-20, you play it by yourself, but still refer to Cpuinfo
If it's a version of Windows, use it like this:
1, will cppcheck Green version Cppcheck.rar decompression;
2, open cppcheckgui.exe;
3. Menu check->directory;
4, select the source code directory, confirm;
5, Cppcheck automatically began to walk the check;
Installation and use of Cppcheck