Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: new style declarations OK for old style definitions? Message-ID: <652@taumet.com> Date: 4 Apr 91 16:40:04 GMT References: <14590@life.ai.mit.edu> Organization: Taumetric Corporation, San Diego Lines: 41 tmb@ai.mit.edu (Thomas M. Breuel) writes: >K&R/2 is a little vague on the following question: under what >circumstances is it legal to declare using new-style syntax a >separately compiled function that was compiled with an old-style >definition. >Is it sufficient to use only promoted arguments in the new-style >declaration? You must not use char, short or float arguments in any of the declarations (nor in the ultimate function header). The function must not accept a variable number of parameters, and the prototype must not include the ellipsis (...). These rules will allow portability of the code. >Conceivably, the whole calling sequence for old style and new style >definitions could differ. Is it legal for the compiler to choose >completely incompatible calling sequences for old-style and new-style >declarations? Not when the above rules are followed. If you violate any of these rules, a conforming compiler is allowed to use different calling sequences. >It would certainly be desirable, since new-style >declarations seem to allow for significant optimizations that aren't >possible with old-style declarations. Yes. Prototyped functions may use different parameter passing for chars, shorts, and floats, and would do so if they are more efficient. In particular, when a function is declared with an ellipsis, the compiler may use a different method of passing the extra parameters than if you call a non-prototyped function. >This is a frequent problem if you have old library binaries and >sources but want the extra type checking from an ANSI compiler. > Thanks, Thomas. -- Steve Clamage, TauMetric Corp, steve@taumet.com