Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!ncar!elroy.jpl.nasa.gov!jpl-devvax!david From: david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) Newsgroups: comp.lang.c Subject: Re: Func Protos with K&R Func Defs Message-ID: <11634@jpl-devvax.JPL.NASA.GOV> Date: 28 Feb 91 21:01:03 GMT References: <11614@jpl-devvax.JPL.NASA.GOV> <1991Feb28.021715.18153@athena.mit.edu> <1991Feb28.072947.28885@athena.mit.edu> <1991Feb28.192849.23235@athena.mit.edu> Reply-To: david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 51 scs@adam.mit.edu (Steve Summit) writes that ANSI C may well stop supporting old-style function definitions at some time in the future. Therefore he recommends that writing K&R style definitions is probably a bad idea in the long term. Well, the problem is this: ANSI is not portable, K&R is. Oh, I know I know I know. But hear me out: I actually wanted to use ANSI for the Widget Creation Library, and initially implemented it using ANSI. Problem: Many, many people could not compile it! So, I went back to K&R. Now its portable. The reason I provide the ANSI function protos in decls is just in case somebody, somewhere ONLY has and ANSI compiler (which of course still understands K&R function definitions). It is true that Wcl is not totally portable, and perhaps one of the problems is that I may not have been careful enough somewhere in making certain that I'm never using non-promoted arguments to functions. It seems that one *must* write code which works with or without prototypes just to be sure that it is portable. I.e., perhaps the correct approach is that suggested by the person who write that whenever you have ANSI prototypes, you also have K&R declarations as well as K&R definitions, is correct. Perhaps even more important that portability is simply interoperability on a single platform. If your functions work identically with or without prototypes (int-size or double arguments only) then people can mix libraries and applications which have been built using different compilers. So, I'll bet that if a C compiler did NOT compile K&R C, it probably would in fact be alot less useful than one that did. Since compilers are generally written by people who for one reason or another want the compiler to be useful to many people, I doubt if we will see good compilers which understand only ANSI declarations and definitions. I could very, very, very easily be wrong. I'm not a prophet, like Saddam or anything ;^) ------------------------------------------------------------------------- David Smyth david@jpl-devvax.jpl.nasa.gov Senior Software Engineer, seismo!cit-vax!jpl-devvax!david X and Object Guru. (818)393-0983 Jet Propulsion Lab, M/S 230-103, 4800 Oak Grove Drive, Pasadena, CA 91109 ------------------------------------------------------------------------- One of these days I'm gonna learn: Everytime I throw money at a problem to make it disappear, the only thing that disappears is my money... -------------------------------------------------------------------------