HP C Programmer's Guide (92434-90009)

168 Chapter7
Using C Programming Tools
Using lint
Using lint
The main purpose of lint is to supply the programmer with warning messages about
problems with the source code's style, efficiency, portability, and consistency. The lint
command can be used before compiling a program to check for syntax errors and after
compiling a program to test for subtle errors such as type differences.
Error messages and lint warnings are sent to standard error (stderr). Once the code
errors are corrected, the C source file(s) should be run through the C compiler to produce
the necessary object code.
The lint command has the form:
lint [
options
]
files ... library-descriptors ...
where
options
are options flags to control lint checking and messages,
files
are the files
to be checked that end with .c or .ln, and
library descriptors
are the names of
libraries to be used in checking the program.
The options that are currently supported by the lint command are:
-a Suppresses messages about assignments of long values to variables that
are not long.
-b Suppresses messages about break statements that cannot be reached.
-c Only checks for intrafile bugs; leaves external information in files suffixed
with .ln.
-h Does not apply heuristics (which attempt to detect bugs, improve style,
and reduce waste).
-n Does not check for compatibility with either the standard or the portable
lint library.
-o
name
Creates a lint library from input files named llib-l
name
.ln.
-p Attempts to check portability to other dialects of C language.
-s Checks for cases where the alignment of structures, unions, and pointers
may not be portable.
-u Suppresses messages about function and external variables used and not
defined or defined and not used.
-v Suppresses messages about unused arguments and functions.
-x Does not report variables referred to by external declarations but never
used.
-Aa Invokes lint in ANSI mode.
-Ac Invokes lint in compatibility mode. The default is compatibility mode.
The names of files that contain C language programs should end with the suffix .c, which
is mandatory for lint and the C compiler.