JB Enterprises How To Wield PC Lint 2009.01.16
Johan Bezem
htwpl.doc Page 3 of 12
source files in the command line for PC Lint of the Makefile". Since the Lint option files do not
have any possibility for conditionally including options, this seems a viable way to go.
Source filenames on the command line
Those of you working with UNIX (or Cygwin, or…) are lucky for having a very long command
line (usually 4096 characters or larger). Those of us working with Windows (or even MS-DOS,
yes, they're still among us!) usually have to stay below 256 or even 128 characters per
command. So, unless you're into very small projects, the command line will be too small
(sometimes even on UNIX!) for listing all relevant source files on one command line.
I usually direct my Makefile to create or update a file called
files.lnt
with all the C/C++
source file names making up the final executable. This would be the fourth (or fifth) filename
to be included on the Lint command line.
Where to send the output
One more issue has to be addressed before we can present the full command line. Lint is a
tool, apparently made by programmers for programmers. It doesn't offer a flashy GUI, where
you can point-and-click through your messages. It used to be a DOS program (I do not know,
whether a UNIX variant has been available in those days), and as far as I know it will still run
on MS-DOS in the current version. So it was and is restricted to two output channels,
stdout
and
stderr
(by default, your screen is targeted). The screen is not a very efficient recipient of
information, especially when the amount is as large as Lint will happily make it. Lint-runs to
the screen easily take 20 times as long compared to redirecting the output to a file, when
running a command line under Windows (
CMD.EXE
).
Most command shells, including the Windows DOS-box, offer redirection possibilities. If you
like, use those. However, command shells are all different, both in behaviour and in syntax.
Therefore, I use the option offered by Lint: -os(lintout.out).
Where to put this option?
loptions.lnt
would present itself, since the (single) output
filename will probably remain the same over projects. But if the project (-manager) dictates
such a name,
projects.lnt
would be perfect.
temp.lnt
shall remain empty.
I put this option on the command line, for one reason: When integrating Lint in your Makefile,
you'll probably use a make-target called "lint" or "lint_all". If, as far as the make program is
concerned, the error file can be viewed as another make-target, make can decide for itself,
based on file timestamps, whether a new Lint run is necessary. In that case, the filename will
be integrated in the Makefile, so it would be natural to be able to include it on the Lint
command line. Even name changes between projects can easily be accommodated this way.
So, the command line to be used would look like this:
lint-nt -b -os(lintout.out) loptions.lnt project.lnt temp.lnt
individual.lnt … files.lnt
(The dieresis '…' indicates that this command line is just one, broken in two for layout
reasons).
One word of warning: The -os option needs to be given before the first output-generating
option is presented on the command line (directly or indirectly), but, especially in a Makefile,
you would not want one of the options files to override the value presented on the command
line. Therefore, the position of the -os option has been chosen for a reason.
See also the use of +flm in
loptions.lnt
.
My global options
The file
loptions.lnt
hasn't got much to do with the task at hand, but just to get a starting
point I'll present the options I usually use, with a few remarks.