Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!aplcen!haven!mimsy!tove.cs.umd.edu!cml From: cml@tove.cs.umd.edu (Christopher Lott) Newsgroups: comp.lang.c Subject: Re: Can lint help an ANSI-C programmer? Message-ID: <24660@mimsy.umd.edu> Date: 30 May 90 18:00:41 GMT References: <6328.265D8157@puddle.fidonet.org> <1754@tkou02.enet.dec.com> <00937758.16FBE220@rigel.efd.lth.se> Sender: news@mimsy.umd.edu Reply-To: cml@tove.cs.umd.edu (Christopher Lott) Organization: The University of Maryland Dept of Computer Science Lines: 28 A few thoughts about lint, prompted by this posting: In article <00937758.16FBE220@rigel.efd.lth.se> e89hse@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@cs.umd.edu 4122 AV Williams Bldg 301-454-8711