Introduction to PC-Lint, a C ++ language code Check Tool

Source: Internet
Author: User
C ++ language code check tool PC-Lint introduction-Linux general technology-Linux programming and kernel information, the following is a detailed reading. Overview

PC-Lint is a static code detection tool with a long history and powerful functions. Its history can be traced back to the ancient times of computer programming (more than 30 years ago ). After so many years of development, it not only monitors many potential operators in syntax logic, but also effectively helps you to improve the space utilization and running efficiency of many programs, in many professional software companies, such as Microsoft and PC-Lint, no errors and no warnings are the first priority of code. I personally think that for small companies and personal development, PC-Lint is also very important, because based on the development cost considerations, small companies and individuals often cannot come up with a lot of comprehensive tests. At this time, the powerful features of PC-Lint can improve the quality of software.

Function

1) PC-Lint is a kind of static code detection tool, it can be said that PC-LINT is a more rigorous compiler, not only can check the general syntax errors as a normal compiler, it can also check out errors that are likely to be potential and hard to be found, although fully compliant with syntax requirements.

2) PC-lint can not only detect a single file, but also detect problems from the perspective of the entire project, because the C language compiler inherent in a single compilation, these problems are difficult to detect in the compiler environment, while PC-Lint checks the current file and all related files, it will be of great help to us.

3) PC-lint supports almost all popular editing environments and compilers, such as Borland C ++ from 1. x to 5. x versions, Borland C ++ Build, GCC, VC, VC.net, watcom C/C ++, Source insight, intel C/C ++, etc, it also supports 16/32/64 platform environments.

(4) various methods to improve efficiency and prevent errors described in Scott Meyes's popular C ++/More Effective C ++.

Overview

This is a good tool that can be used first. Here we will divide it into four steps to ensure that you can use PC-Lint immediately. Of course, if you get started, if you want to learn this tool in depth, you can find relevant materials on the Internet, another article in my series, "Seven Weapons of Software Development", tells about the use of PC-Lint, which is more detailed than this article. If you are interested, you can also take a look.

Step 1: Install and set

Installation is no different from normal software. After installing the plug-in, run config.exe in the pc-lintinstallation directory. The configuration is briefly described as follows:

A) Step 1: Provide the installation path of PC-Lint and select the save file for the settings.
B) Step 2: select the C/C ++ compiler you are using, for example, Visual C ++ 6.x.
C) Step 3: select the memory mode, for example, 32 bit Flat Model.
D) In Step 4, select the library used, for example, MFC, OWL, and so on. You can select multiple databases. For windows development, select windows 32 bit.
E) in step 5, the author of C ++ programming puts forward important suggestions. After selecting an author, the options of his programming suggestions will be opened, such as Scott Meyers.
F) Step 6: Set the header file: You can manually add it in the subsequent steps.

Step 2: integrate PC-Lint to the selected compiling environment

After you select the compiler in step 2, you can find an "env-selected editing environment" in the PC-Lint directory. lnt "files, such as env-si.lnt for Source insight and env-vc6.lnt for vc6. Open this file and configure your compiler as described above. The following uses VC6 as an example:

· Select menu tools | customize .....
· Select Tools labels
· Click the dotted box New at the top of the Main Dialog Box
· Input name: PC-LINT
· Input Command: c: \ lint \ lint-nt.exe, assuming installation to this path
· Input Arguments: c: \ lint \ std. lnt? (FilePath )? 7) Select (x) Use Output Window
· Close

Step 3: Lint a single C file

A) open a C file.
B) Run step 2nd. PC-Lint menu items on step integration
C) the LINT result will be displayed within one or two seconds. For more information about alerts, see the MSG. TXT file in the LINT installation directory. open the file and locate the alert number.

Step 4: Lint multiple C files

A) Create PRJLINT under the LINT Software Directory. LNT file. The first line of the file is the name of the LINT configuration file used. From the second line, list all the LINT files you want *. C file name, one row. If you want to output the result to a file, add a line "-OS (File Name)" (for example: "-OS (c: \ lint \ result.txt)") to the front )"). Example: YF_Config.lnt
// The following is the. C file for Lint,
G: \ src \ tt \ tt1.c
G: \ src \ tt \ tt2.c
...

B) Add a "PC-LINT PROJECT" command in the method described in Source Insight, all settings are the same as "PC-LINT" Settings,

① "Custom Commands" dialog box "RUN" edit box text by "C: \ LINT \ LINT-NT.EXE filename. lnt % f "changed to" C: \ LINT \ LINT-NT.EXE PRJLINT. LINT ", that is, change the configuration file name to PRJLINT. LNT, and remove the unending "% f"

② Set the shortcut key and PC-LINT to distinguish

The following doscommand can be used to get a list of *. C files. For example:

① List all *. C files under C: \ SRC and save them to C: \ SRC \ FILELIST. TXT:

Dir c: \ SRC \ *. C/B> C: \ SRC \ FILELIST. TXT

② List all *. C files in the SRC subdirectory under C: \ SRC and add them to the end of C: \ SRC \ FILELIST. TXT:

Dir c: \ SRC \ *. C/S/B> C: \ SRC \ FILELIST. TXT
Important PC-Lint files
Msg.txt: Describes the alert content.
Selected. lnt: path containing the header file,-I option.
Env-selected editing environment. lnt: describes how to combine PC-lint with the corresponding editing environment.
Co-xxx.lnt: The selected compiler.
STD. LNT: Memory Model and other global things.
LIB-xxx.LNT: library type list, including standard C/C ++ library, MFC Library, OWL library and so on.
AU-xxx.LNT: the author of C ++ programming who has made important suggestions. After selecting an author, his options for programming recommendations will be turned on.
OPTIONS. LNT: Option file that reflects the global compilation information display.

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.