software from Gimpel Software. It can be called a tricky weapon because it can perform much stricter format checking (including but not limited to) than compilers. mainly in processing Windows, MS-DOS, OS / 2 and various systems), in the form of exe files; Another name is FlexeLint, which should be similar to other systems (eg Linux) and released with tracking code.
Since FlexeLint is rare, this article discusses its use in PC-Lint only. the latest version on our official website is 9.0, but it is also not easy to create, so in this article we will consideronly valid for PC-Lint8.0. We’ll also do a little homework to view the code on Linux.
As mentioned above, PC-Lint is definitely applicable to Windows and OS / 2, unfortunately the C standardization is better, so the program has been slightly modified, PC-Lint may well follow the Linux Recommendation
In addition to the operating system environment, you should definitely combine PC-Lint with a build / edit framework. now PC-Lint can be well automated with most of the mainstream writers and compilers, which is very handy.
These aspects are presented below.
2.1. Usage with Linux
GCC has traditionally used Linux as the C interchange compiler. For PC-lint to effectively validate Linux code, users must select the correct file-relative header (. H). these entries are usually stored in / usr / include and / usr / / include directory.
Since PC-Lint cannot work on Linux, you need to map both of the above directories (for drives that can) so that the z folder becomes: / usr / include, not forgetting Z: / usr / / include You can also copy the fa Header Linux to Windows system in real time. The system may ask for a duplicate phone file, but these files are usually not used, they are directly overwritten by / / include)
To enable PC-lint for these two large directories, add
– Iz: / usr / include
-Iz: /usr/3.4.3/include two lines.
Since PC-Lint supports Windows, the product complains about the incorrectness of a small number of header files in Linux. Since our employees are not committed to making changes to the level file, we only need to bring in PC-Lint for now. can do it in all varieties. the following lines are used to create the LNT file:
-E716 // enable wear while (1)
// error in the syslog. H, it _ Need_va_list _ Define a macro
-Efile (537, stdarg. H)
-Emacro (530, va_start) Don’t run // first parameter
Change the most important parameters. Get rid of lnt and no doubt use the GNU filtering rules. Go to the next line:
PC-Lint is assumed to be installed in the C: / pclint directory.
After adjusting these parameters to quickly check the Linux code in Windows.
2.2. Using sourceinsight, sourceinsight
In could potentially create a new team. Typically, in the custom command window, enter the name of the requirement (z / Int-Std. Env-Si lnt% F
In the sample registration form, enter
^ / (. * /. [A- Za -Z] + /) / W / ([0-9] + /) a .. *
Then you can simply run this command to check file 3.
The above configuration is flawless. Once configured, it is ready and hardly needs to be changed. However, there are interesting configurations for other projects as well. This section describes how to set up a specific type of project.
First of all, each project has its own user header file. Hence, you must use the project header file in the STD listings. LNT. The format is as follows:
-I For example:
-IZ: / sw-new / src / license
Moreover, if several directories represent a third party project or all have done it, ignore the warnings, you can specify these directories articles as library catalogs. The format is considered as follows:
+ Libdir (, …)
+ Libdir (z: / usr / include, z: /usr/3.4.3/include, z: / mysql / include)
For projects that have not been tested yet, many warnings and errors may appear during the first PC-Lint check … not intended to hide useful errors in warnings. configure the global validation level, located in lnt, to show only major deviations. Method:
The more the number of levels, the more jack warning errors. We recommend that you gradually increase the number of errors and warnings that have occurred yourself. For example
You can also
Error checking will be temporarily suspended.
4. Avoid fatigue – there might also be a situation where you trust some computers – determine if your own arguments are enough, don’t prefer this conclusion Oh 🙂 —- Optional, however PC -Lint complained every time when I read it. In this case, PC-Lint easily skips certain checks by adding exclusive comments to the code.
PC-Lint offers a large number of special comments that you canadd to code.
Inspection control of small grain. Continuation
, which lists several repeating options. For more options, see the complete PC-Lint User Guide. Note what these parameters should be to help you with C code comments in the format / * lint * /. The required lint appears immediately after / *, and specifies the parameter, leaving every space after the * / parameter.
1) .- e (# [, #] …) applies only to what follows the expression,
A = / * lint-e (413) * / * (Char *) 0;
A = / * lint-save-e413 * / * (Char *) 0
/ * Lint-Restore * /; Film Equivalent.
2). – e (# #] [, …) applies to the whole expression,
A = / * lint – elizabeth (413) * / * (Int *) 0 + * (Char *) 0;
Processing of two messages 413 is definitely blocked, and the first exit point 413 is blocked forever with -e (413).
3)). -orite # [, #] … Valid for the next statement or statement. the scope of the results of this use at this stage is flexible: applied to the full function before the function; they apply to the appraisal document before the appraisal report; inIfOrWhile before its instruction.
4)). – from to [, #] … this is valid for all the code it contains, including the function body, sorting, and structure. if far, then good for the whole file (of course, with -e at the end of the application).
5).! E # is currently only for the line where the software resides.
6) .- esym (#, sym [, save sym]) symbol specified as warning.
5. General error handling
Here are some known bugs and solutions:
525 Most errors occur because abbreviation code is mistaken for a TAB trick. PC-Lint believes that the code as a whole does not match the code that follows this logic. change it to encode the space. .
Symbol 715 is not actually referenced because the Speak With option or local variable is not used in the assignment for you. You can delete the local variable directly and pl ParameterIfStatement also ask for fancy type conversion.
740. In general, if the classification of pointers is being converted and the number of spaces given in the hint before and after the conversion is probably inconsistent, you can use
/ * Lint-e (740) * /
To Block add Write this warning.
818 A function hint parameter has not been changed within a function. This is because the parameter defines a constant pointer. Const It looks like PC-Lint may have an ERROR when reconciling this issue, even the ifConstThe modifier may still throw this warning. In this case, warning 818 for the proposed parameter to this function should be blocked by adding a method before the intent starts.
/ * Lint-esym (818, pointer) * /
/ * Lint Esym + (818, pointer) * /
promo code 827 is not available, because inWhile (1) / For ( ;), but the mode is never executed. The technique is to add
/ * Lint-unreachable * /
<1> not because it was done in the Year of the Ox, but because it’s really cool.
<2> This indicates the current version of GCC, eg 3.4.3.
<3> assuming the CD is assigned to drive Z.
<4> The reason is that Linux filenames are case sensitive and Windows clips are not garbage sensitive.
<5> This kind of work can be done by indentation. Trust me, it can be good for you.