Path: utzoo!attcan!uunet!samsung!think!mintaka!bloom-beacon!eru!luth!sunic!lth.se!E89HSE@rigel.efd.lth.se From: e89hse@rigel.efd.lth.se Newsgroups: comp.lang.c Subject: Re: Can lint help an ANSI-C programmer? Message-ID: <009377E6.C32DAB80@rigel.efd.lth.se> Date: 31 May 90 14:10:57 GMT References: <6328.265D8157@puddle.fidonet.org> <1754@tkou02.enet.dec.com> <00937758.16FBE220@rigel.efd.lth.se>,<24660@mimsy.umd.edu> Sender: newsuser@lth.se (LTH network news server) Reply-To: e89hse@rigel.efd.lth.se Organization: Lund Institute of Technology,Lund, Sweden Lines: 31 In article <24660@mimsy.umd.edu>, cml@tove.cs.umd.edu (Christopher Lott) writes: >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. > >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)" But you don't have to have lint to do that, in fact TurboC will warn you for that. >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. Well, I've found that 99% of the times I write: printf("name=%s\n"); I just don't care about the return value... Lint warnings about igonred return values have never helped me up to now, just bothered me. (BTW if exit() is properly declared there won't be any warning.) > Lint can also help detect >nonportable constructs, but I can't think of a good example just now. Yes, but a compiler could warn you about that. (I'm not sure if anyone do.) If you write something like: printf("ASC(%u)=%c\n",++c,c); you'd better go back a take a look at the text books... Henrik Sandell