Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!amdahl!drivax!socha From: socha@drivax.UUCP (Henri J. Socha (x6251)) Newsgroups: comp.lang.c Subject: Re: Function prototypes (enforced) Message-ID: <1460@drivax.UUCP> Date: Fri, 1-May-87 18:26:47 EDT Article-I.D.: drivax.1460 Posted: Fri May 1 18:26:47 1987 Date-Received: Sun, 3-May-87 03:52:52 EDT References: <18346@ucbvax.BERKELEY.EDU> <7973@utzoo.UUCP> <796@rtech.UUCP> Reply-To: socha@drivax.UUCP (Henri J. Socha (x6251)) Organization: Digital Research, Monterey Lines: 55 Summary: compiler should force prototype definitions on all functions In article <796@rtech.UUCP> jas@rtech.UUCP (Jim Shankland) writes: >Henry Spencer (utzoo!henry) notes in passing: >> [Function prototypes] have other problems, and I'm not sure they were a >> good idea.... >This got me curious: what are the problems with function prototypes? >The only one I can think of is that an implicit coercion will not be >done when there is no function prototype in scope. I would resolve >that by requiring compilers to emit a fairly strongly worded warning >whenever a program called a function without a prototype in scope. >Are there additional arguments against function prototypes? If so, >what are they? Well, just to back up (give an example) of what you said: The Macintosh Lightspeed C (development environment!) from Think Technologies has an option called "Function Prototypes Required". It can be set as a default that is always enforced (unless explicitly disabled). They also have a non-standardism (which I feel is a bug) in that when a function is defined, the prototype form CAN NOT be used. Therefore if this option is enabled, you must say: int main(int argc, char *argv[]); int main(argc, argv) /* can't use prototype form here! (bug) */ int argc; char * argv[]; { ..... } Or you will get a compile error that the prototype for main was not given. YES, (before you flame me) a prototype declaration at function definition should be allowed but (and finally this is the point): I WOULD RATHER BE FORCED TO DO UNNECESSARY DECLARATIONS THAN NOT KNOW IF ALL FUNCTIONS AND CALLS HAVE BEEN CORRECTLY CODED. I have been burned more than once by the missing declaration of an external LONG returning function or a mis-typed call argument. How about it compiler writers? Will you also install a switch that DEMANDS prototype definitions for all functions so that at least a minimum of type checking can be performed? Disclaimer: This is not (necessarily) the view of my employer. -- -- UUCP:...!amdahl!drivax!socha WAT Iron'75 "Everything should be made as simple as possible but not simpler." A. Einstein