Using LINT to cleanup your code
If your code compiles, but doesn't run as well as you expected, try using
"lint" to help you clean up your code. Lint, according to its manual page:
Lint attempts to detect features of the C program files which are
likely to be bugs, or non-portable, or wasteful. It also checks the
type usage of the program more strictly than the compilers. Among the
things which are currently found are unreachable statements, loops not
entered at the top, automatic variables declared and not used, and
logical expressions whose value is constant. Moreover, the usage of
functions is checked to find functions which return values in some
places and not in others, functions called with varying numbers of
arguments, and functions whose values are not used or whose values
are used but none returned.
To use lint, type:
lint file.c
If your source code involves more than one file, the format is:
lint file1.c file2.c file3.c
Note that lint works on files written in traditional C (i.e., code
conforming to Kernighan and Ritchie, 1st edition). It will not work
for ANSI C files. If you are writing in Ansi C and wish to check your
code, you can use Saber. You may, however, find that your compiler
gives you adequate information to clean your code of those basic
errors that lint would catch.
Also, even if your code DOES run well, it's usually desirable to write
"lint-free" code.
For further information on lint, type the following at your athena% prompt:
man lint
Last Updated: 7/25/96
|