Can lint help an ANSI-C programmer?

Christopher Lott cml at tove.cs.umd.edu
Thu May 31 04:00:41 AEST 1990


A few thoughts about lint, prompted by this posting:
In article <00937758.16FBE220 at rigel.efd.lth.se> e89hse at rigel.efd.lth.se writes:
> I don't see what lint discovers that a C-compiler with prototypes can't
>discover, except wrong external declarations like: hello[100], char *hello.

The use of function prototypes is very helpful, but interface
errors are not the only class of errors out there!

Lint will bring many common constructs to your attention.
An example is doing a test on a constant expression, like
"if (i = 1)" where the programmer perhaps meant "if (i == 1)" 
Another example is of functions returning values which are ignored.
This warning causes much irritation for functions like "exit()" but
can point the way to a fault in the code.  Lint can also help detect
nonportable constructs, but I can't think of a good example just now.

Someone please correct me if some compilers flag these sorts of faults.
gcc, for one, does not flag test-of-constant conditions, not even when
told "-Wall -ansi -pedantic"

For PC users, Gimpel Software sells PC-Lint, and it is an excellent
product.  It understands ANSI-style function prototypes.
I convinced my old boss to buy it, and the package was very helpful.

chris...
--
Christopher Lott    Dept of Comp Sci, Univ of Maryland, College Park, MD 20742
  cml at cs.umd.edu    4122 AV Williams Bldg  301-454-8711 <standard disclaimers>



More information about the Comp.lang.c mailing list