Use cppcheck to check the code

Source: Internet
Author: User
Use cppcheck Code

(Jinqing's column)

Cppcheck is an static analysis tool for C/C ++ code.

Cppcheck homepage:
Http://cppcheck.sourceforge.net/

For instructions, see:
Http://cppcheck.sourceforge.net/manual.html

After you download and install cppcheck, you can test it as follows:

D: \ temp \ cppcheck -- enable = all -- template = vs D: \ code \ Server 2> D: \ temp \ result.txt

Open all check items and use the incorrect report format of vsto export the result to result.txt.

For ease of use in VC, create a BAT file, vscppcheck. bat

Cppcheck -- enable = all -- template = vs % 1> NUL

Because only cerr output is required, cout is output to NUL.

Then, choose vs> Tools> external tools to add:

Title: cppcheck
Command: D: \ jinq \ vscppcheck. bat
Parameter: $ (solutiondir)
Use Output Window

After setting this parameter, you only need to click the cppcheck menu to output the code check result and press <F4> to jump to the error line.

The trial results show many errors that should pass in parameters by reference but PASS Parameters by value, such:
D: \ code \ Server \ region \ logic \ roommgr. cpp (20): Performance: function parameter 'sroomname' shocould be passed by reference.

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.