Installation and use of Cppcheck

Source: Internet
Author: User

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/



    1. Enable to check the rules:
      1. Default:--enable=error
      2. --enable=all
      3. --enable=unusedfuntion Path
      4. --enable=style
    2. Rule definition:
      1. Error: Errors that occurred
      2. Warning: Recommended information for preventing bug-defensive programming
      3. Style: Coding format problem (no functions used, extra code, etc.)
      4. Portablity: Portability warning. Compatibility issues may occur if this section is ported to another platform
      5. Performance: It is recommended to optimize the performance of this part of the code
      6. Information: Some interesting information that you can ignore without looking at.
    3. Save results to file: redirect >
    4. -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

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.