Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/3/85; site ukma.UUCP Path: utzoo!watmath!clyde!cbosgd!ukma!david From: david@ukma.UUCP (David Herron, NPR Lover) Newsgroups: net.lang.c Subject: Re: C Builtin Funxions Message-ID: <3186@ukma.UUCP> Date: Sun, 20-Apr-86 17:45:46 EST Article-I.D.: ukma.3186 Posted: Sun Apr 20 17:45:46 1986 Date-Received: Wed, 23-Apr-86 20:40:58 EST References: <2524@brl-smoke.ARPA> <2554@utcsri.UUCP> Reply-To: david@ukma.UUCP (David Herron, NPR Lover) Organization: U of KY Mathematical Sciences Lines: 53 In article <2554@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes: >In article <2524@brl-smoke.ARPA> rbj@icst-cmr (root) writes: >>... >... >On related point ( I'll explain why ), do y'all remember "Weird C >behaviour"? One of the problems being that printf was being passed the >wrong types? > >Well, lint can't catch this sort of thing because it is told by >/*VARARGS*/ to keep its cotton-picken hands off any call of printf. >Anyway, in order to check this, it needs to know (1) that printf,fprintf, >sprintf are special cases, (2) how to interpret printf format strings. >The format may be known only at run-time: printf(fmt_string,...). >However, in view of the facts that printf's are frequent, and that mistakes >in parameter types are fairly common, and that 95% of printf calls have >string constants for formats, I would like to see lint do this. If >the format parameter was not a string constant, you would be on your >own of course. ... Ok, there *is* a way to do this. One of the europeans (that guy that had been doing Hack) posted a tool for aiding lint last year sometime. It read through C programs looking for printf() calls. It looked at the format string and for the associated arguments it inserted a function call, something like: int retint(i) int i; { return i; } /* ... more similar functions ... */ f() { ... printf("i is %d\n", retint(i)); ... } Now, if i is not an int then lint will know that it should be and bitch. Also the retint() calls can be gotten rid of with: #define retint(i) (i) >... The following is a borderline case: > > printf( c<' '|| c>'\176'? "\\%3o":"%c", c); I dunno what it would do with this case... One thing that occurs to me... do char's always get casted to ints when they're arguments to functions????? -- David Herron, cbosgd!ukma!david, david@UKMA.BITNET, david@uky.csnet