PC-lint Instructions For Use

 Objective

The following step-by-step instructions will show you how to setup PC-lint for a project in MPLAB® X IDE. To start, make sure you have the following installed:

and the

For this specific example we are running a MISRA C 2012 (TM) check.

 Procedure

1

To be able to run a MISRA12 check for example, you need the following config-files:

  • au-misra3.lnt - MISRA checks to run
  • co-xc8.lnt - XC8 compiler config-files

Make sure you have the latest version of these configuration files. They can be obtained here.

2

Create an UserOption file that contains the following:

  • path to check-config-file = “au-misra3.lnt
  • path to compiler-config-file = “co-xc8.lnt
  • path to compiler header files

Below is an example of how it looks for this specific tutorial:

//  Microchip MPLAB XC8 C, -si4 -sp4, 
//  Standard lint options
// -SL-3.3.16: Based on input, setup this configuration
C:\lint\configSL\au-misra3.lnt
C:\lint\configSL\co-xc8.lnt
// C:\lint\options.lnt  -si4 -sp4
-i"C:\Program Files (x86)\Microchip\xc8\v1.36\include"

As we can see from above, this option file includes the path to the lnt file that needs to be run for MISRA standard, the path to the lnt file specific to XC8 compiler, and the path to include compiler header files.

3

Configure PC-lint in MPLAB X by going to “Tools > Options > Embedded > PCLint”:

  • Location - path to your PC-lint installation “lint-nt.exe
  • Options - select UserOptionFile
  • User Option File - select the UserOption file you created in the previous step
  • Standards - MISRA2012
PCLintOptionsEntered.gif

4

You also need to create two more config-files “include-path.lnt” and “lint-cmac.h” as described in the header of the “co-xc8.lnt” file.

Both files contain the information that is usually passed via compiler-options “-i xxx” in include-path.lnt and "-D xxx“ in lint-cmac.h.

See header of co-xc8.lnt for a more detailed explanation on how to create these two files.

5

For MPLAB XC Compilers, PC-lint requires include-path.lnt and lint-cmac.h for linting. These two files can be generated from the MPLAB X IDE project context menu item “Generate PCLint Dependency Files”. Selecting this item will add both dependency files to the c:\pclint\lint\lnt folder.

ContextMenuPCLint_DependencyFiles.png

6

Finally right-click on the project in the MPLAB X and select “Lint this Project

ContextMenuPCLint_LintProject.png

 Results

You will then see an output like the one below

output2.jpg

The output will contain the file name(s) and line number(s) in which linting found inconsistencies. Double clicking an output line will open the corresponding file at the line number in the MPLAB X IDE editor window.

© 2017 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.