Software Quality path: PCLint 2, quality path pclint

Source: Internet
Author: User
Tags visual studio 2010

Software Quality path: PCLint 2, quality path pclint

Why can I draw a circle? Because the foot is walking, the heart remains unchanged. Why can't you dream? Because of uncertainty, the feet do not move.

 

1 beacon and direction

Time passed so fast, I still remember the cherry-red banana green season, in the twinkling of an eye has entered the late autumn. I love nature, followed by art. The Art of Computer Programming is still in The pile of books, so he has no courage to pick up The weight.

Today is a wonderful day. I don't know if I have seen the light of the beacon. The light suddenly shines so brightly and flustered. The excitement is hard to calm down, and I feel that there will no longer be such a complex mood in my life. Suddenly, the day of hope is the greatest happiness in my life!

PCLint, the second member of the path to software quality, introduced the installation, configuration, and upgrade of PCLint in the previous article, this article focuses on how to add PCLint as a tool to a common development environment and become the left and right sides of our development process.

Note: in the previous article, the PCLint tool was updated. Please download the tool again for two reasons. First, the original tool should be a problematic version. After the upgrade, the project file of Visual Studio cannot be correctly parsed, it took me more than a week to investigate the cause of this article. 2. Added configuration files for Visual Studio 2010,201 2 and 2013 for your convenience.

 

2 PCLint command line

PCLint mainly uses the command line mode for File Parsing. The GCC compiler process is very similar. The command line format is:

Lint options file1 [file2 file3. ..]

Since PCLint can be used as a compiler, options is the compilation option, and file is the file to be compiled. For C ++, it is mainly *. cpp file, because *. h is used as the inclusion file and will not be compiled separately. Therefore, pay attention to this.

If you check a project file, you need to generate a file list, similar to the Makefile file.

The following describes the specific configuration methods of each tool. For more information about the parameters, see the manual in the installation directory.

 

3. Configure Visual Studio 3.1 to scan and create a cpp file list

This process is the list of generated files mentioned above. In Visual Studio, files are mainly created by project (or directory.

1. Select a tool and create an external extension tool.


2. Create an external extension tool named PCLintCreation.


The parameters are as follows:

Title: PCLintCreation

Command: the installation path \ lint-nt.exe

Arguments:-v-OS ("$ (TargetName). lnt") "$ (ProjectFileName )"

Initial directory: $ (ProjectDir)

3. Similarly, the shortcut keys can be allocated based on the SourceMonitor configuration in the previous article.


4. Execute the added PCLintCreation. A corresponding *. lnt file is generated under the corresponding project file path. The content is as follows:


5. Note that when files in the project change, you need to re-execute the task to ensure the correctness of the file list.

 

3.2 check all files under the project

Perform a PCLint check based on the file scanned in the previous step.

1. Select a tool and create an external extension tool. This is the first step in the following section.

2. Create an external tool named PCLintCheck.


The parameters are as follows:

Title: PCLintCheck

Command: D: \ lint \ lint-nt.exe

Arguments:-I "D: \ lint" std. lnt env-vc12.lnt "$ (TargetName). lnt"

Initial directory: $ (ProjectDir)

Note the following points: first, because PCLint may not support C ++ 11 as widely as Visual Studio 2013 does, the detection fails, therefore, it is not recommended to use Visual Studio 2013 or later. Second, the first lint file, std. lnt is the file generated for the configuration in the previous article, the env-vc12.lnt is the configuration file for VC12 (Visual Studio 2013), "$ (TargetName ). lnt is the list of files scanned for the project in the previous step. Third, if the *. lnt file is missing, copy the corresponding file to the PCLint installation path.

3. Execute PCLint. The corresponding Info, Warn, Error, and Fatal information will be Output in the Output window, so that the corresponding code can be viewed and corrected based on the information.


 

3.3 check a single file

If you only check a single file, you do not need to configure the first two steps. However, this step is only valid for a single file and is not convenient for Ant tasks. However, compared with the entire project inspection, the efficiency is relatively high, so it is suitable to quickly check files and modify problems, the specific configuration is as follows.

1. Select a tool and create an external extension tool. This is the same as the previous one.

2. Create an external tool named PCLintCheckItem.


The parameters are as follows:

Title: PCLintCheckItem

Command: D: \ lint \ lint-nt.exe

Arguments:-I "D: \ lint" std. lnt env-vc12.lnt "$ (ItemFileName) $ (ItemExt )"

Initial directory: $ (ItemDir)

3. Execute PCLint to check the current file and Output the result to the Output window. For example:


Of course, the execution fails because Visual Studio 2013 is used as an instance. This execution on Visual Studio 2012 is normal.

 

4. Further consideration

At the end of the article, I found that this article was a little sloppy. Unfortunately, PCLint cannot keep up with C ++ 11 and Visual Studio. We hope that the developers of PCLint will continue to update this excellent tool.

Of course, the tool is only part of it. Never put everything on the tool. In fact, as long as good code specifications are observed, the chance of making mistakes will be minimized, and PCLint is just a guiding role, which is my understanding of this tool.

I 'd rather be a monk and adapt to a tough environment. When I come back and look at these Warning, Error, or Fatal, it's just a big smile, I suggest you have time to read Matthew Wilson's book Inperfect C ++. I believe you will also agree with my opinion, that is, the author's opinion. Of course, as the author said, if you have a certain understanding of the series of Objective C ++ and the series of Objective C ++, and you have already had the TCPL in hand, this book will not disappoint you if you have a certain understanding of the template. Well, at least after I read this book, I can't bear to look straight at the Perfect C ++ I wrote.

I'm so excited that I still cannot calm down. I plan to remove these articles from the Perfect C ++ series and put them into the QA series. This is a summary.

In addition, I have recently made some research and achievements on natural language processing. Although most of them are based on previous ideas, I also want to summarize and share my own research, I would like to take this opportunity to deepen my understanding of this part of knowledge, and hope that various great gods can discuss and learn from each other and improve their knowledge together!


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.