Pc-lint Concise Tutorials

Source: Internet
Author: User
Tags vc9

Objective

Pc-lint is a small, powerful, C + + static code-checking tool that checks for potential errors that are difficult to find by compilers such as uninitialized variables, array bounds, null pointers, and so on. In many professional software companies such as Microsoft,pc-lint check error-Free without warning is the first level of code to pass first.

Installation configuration

For installation steps, please refer to the appendix of the article "Static Code inspection Tool Pc-lint" "4 Pc-lint Software use method", but the article uses VC + + 6.0 development environment, the latest Pc-lint 9.0 support VS2008, you can choose during the installation process.

For the integration of Pc-lint and VS2008, please refer to the Env-vc9.lnt file in the Pc-lint installation directory, which is very detailed and does not have to refer to the "Static Code Checker Pc-lint" section of this article (if your e-text is not very good, The reference to Chinese is helpful, too.

In the simple check section of the Env-vc9.lnt file, the following is a piece of content:

Arguments:-i "C:/lint" Std.lnt env-vc9.lnt "$ (itemfilename) $ (itemext)"

It is recommended to use the following new arguments:

Arguments:-i "C:/lint" Std.lnt env-vc9.lnt "$ (itemdir) $ (itemfilename) $ (itemext)"

The effect is to check the result of the code, you can double-click one of the results of a check directly to a line in the code, the disadvantage is to check the result is a bit longer, because it uses the full path.

After the configuration is complete according to ENV-VC9.LNT, there are four pc-lint options under the VS2008 Tools menu, as shown in.

Common errors

1. After the Pc-lint Configuration Wizard finishes, a std.lnt file is generated in the Pc-lint installation directory with one line:

Options.lnt-si4-sp4

If you go through all the standard configurations by using the static code checker Pc-lint OPTIONS.LNT will be automatically generated, but no content (except for annotations), if a step in the middle of skip, it may not be generated, then you need to manually create a options.lnt file, or comment out options.lnt in std.lnt, otherwise you will use Pc-lint will appear To OPTIONS.LNT's error.

Pc-lint installation package also has a OPTIONS.LNT file (not included), can be copied directly to the Pc-lint installation path to replace the original file, I have added some masking error items as an example.

2. In the process of using pc-lint, if there is an error that a library header file cannot be found, you can open the Std.nt file and add the full path of the header file in the following format:

-I. "D:/winddk/7600.16385.0/inc"

3. Pc-lint does not support Unicode Codepage 1200 and 1201, use Unicode (UTF-8 with signature)-Codepage 65001.

Using Pc-lint

After the installation and configuration is successful, it is easy to use pc-lint, as long as you open a VC + + project, click on the "Tools" menu under the four Pc-lint options, the following is the use of the four options differences:

1. Pc-lint (Simple Check)

Only individual files can be checked.

Open a CPP file (or header file) and click Pc-lint (Simple Check).

2. Pc-lint (Project Creation)

Creates a list of files for the project.

Open a VC + + project, click Pc-lint (Project Creation), and then there will be a (project name). lnt file is generated to the project directory. Open the check to see if all the source files are included, and you can modify them manually.

3. Pc-lint (Project Check)

A code check is performed on the entire project.

After the (project name). LNT is created, simply click Pc-lint (Project Check).

4. Pc-lint (Unit Check)

A single file is checked, but the-D and-I options are applied to the (project name). lnt file generated by Pc-lint (Project Creation).

Open a CPP file (or header file) and click Pc-lint (Unit Check).

Summarize

Are you ready to check your code before the leader?!!

Appendix

Static Code checking tool Pc-lint

Http://blog.chinaunix.net/u/30686/showart_408389.html

Pclint Usage Introduction

Http://blog.csdn.net/lbqBraveheart/archive/2010/05/17/5602391.aspx

http://blog.csdn.net/harbinzju/article/details/5844221

Pc-lint Concise Tutorials

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.