turbo-C and lint ?

Charles Noren noren at dinl.uucp
Thu Mar 22 02:11:29 AEST 1990


In article <1966 at bruce.OZ> alanf at bruce.OZ (Alan Grant Finlay) writes:
 >In article <1990Mar20.130947.16583 at cs.eur.nl>, reino at cs.eur.nl (Reino de Boer) writes:
 >In article <1555 at dinl.mmc.UUCP>, noren at dinl.uucp (Charles Noren) writes:
 >Both of these were in reponse to my original query which may not have been
 >specific enough.  Consider the following correct program:
 >
 >check(x,y)
 >long x;
 >char *y;
 >{
 >printf("%10.10s ",y);
 >}
 >main()
 >{
 >check(10l,"testing");
 >}
 >
 >If you now remove the l after the 10 in the procedure call the compiler
 >issues no relevant warnings and the program misbehaves.  Can Turbo-C 
 >generate a warning for this kind of error?

My Turbo C stuff is at home...
but I suggest you use the ANSI C features of the compiler, so your
code would become:

void check(long x, char *y)    /* I always want to explicitly say what the
                                  function returns, in this case nothing
                                  (the previous definition returned an int). */
{
    printf("%10.10s ", y);
}

main()
{
    check(10l, "testing");
}

...now Turbo C, under its default settings, will check the argument
list in the function check().  If the "l" is taken out, Turbo C
will let you know.  Turbo C should also tell you that you did
not use argument x in function check().  These are the "lintish"
features of the compiler.  You can turn off the unused argument
check by using a #pragma statement as documented in the Turbo C
manuals (this corresponds to a same lint capability).

As another poster has mentioned, the default checks on your code
by Turbo C, while more than "standard" C compilers, is rather
limited.  Check the documentation for turning on more of the
checks.


-- 
Chuck Noren
NET:     ncar!dinl!noren
US-MAIL: Martin Marietta I&CS, MS XL8058, P.O. Box 1260,
         Denver, CO 80201-1260
Phone:   (303) 971-7930



More information about the Comp.lang.c mailing list