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:
- PC-lint from the Gimple Software website
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.
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.
Results
You will then see an output like the one below
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.