Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!rochester!ritcv!cci632!ccird2!rb From: rb@ccird2.UUCP (Rex Ballard) Newsgroups: net.lang.c Subject: Re: questions from using lint Message-ID: <759@ccird2.UUCP> Date: Tue, 15-Apr-86 13:17:34 EST Article-I.D.: ccird2.759 Posted: Tue Apr 15 13:17:34 1986 Date-Received: Fri, 18-Apr-86 04:14:23 EST References: <7097@cca.UUCP> Reply-To: rb@ccird2.UUCP (Rex Ballard) Organization: CCI Telephony Systems Group, Roch, NY Lines: 45 Summary: Cleaning it up. In article <7097@cca.UUCP> dewitt@cca.UUCP (Mark DeWitt) writes: >*** REPLACE THIS LINE WITH YOUR MESSAGE *** >I have three questions, the first of which was only brought to my >attention by lint, not caused by it. The code in question works under BSD4.2 >on both vaxes and suns. > >1. I have code with declarations that look like the following: > struct tm *zulu, *gmtime(); > >but I forgot to #include at the top. Pretty careless, >but what is remarkable is that I never noticed until I ran lint on >it. WHY DID THIS COMPILE SUCCESSFULLY? >The lint message was: >warning: structure tm never defined If you did not attempt to access any of the structure members, the compiler would just "fudge" the pointer. If the pointer pointed to an odd address, the execution would have bombed. Compilers are often very forgiving (I have one that exepts newlines as statement terminators, but lint bombs from the syntax errors). > >3. How do you get lint to shut up about variable numbers of arguments >with stdio functions like printf, scanf, etc.? I tried using /*VARARGS*/ >right, left, and sideways to no avail. The doc is not great, but you >knew that already. The /*VARARGS*/ escape has to be put just before the code that defines the function. ie: /*VARARGS1*/ printf(s,p) char *s; int p; { int i; return(i) }; this should have been done when your lintlib was created. You may need to re-create the lintlib. There are usually skeleton definitions in the same directory as the lintlib (4.2). V7 had these declarations in source form only. >After three years of C programming I'm just starting to use lint, so >please no negative reinforcement by flaming about how stupid my questions >are, lest I give up on it entirely :-). YAHOO!!! GOOD FOR YOU!!! :-). You have taken a good step into the realm of clean, portable code. We've cut our debug time by 60-70% doing this, and reduced maintenance costs as well. There is really no justification for not using lint.