Can lint help an ANSI-C programmer?

e89hse at rigel.efd.lth.se e89hse at rigel.efd.lth.se
Fri Jun 1 00:10:57 AEST 1990


In article <24660 at mimsy.umd.edu>, cml at tove.cs.umd.edu (Christopher Lott) writes:
>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.
>
>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



More information about the Comp.lang.c mailing list