Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!mp.cs.niu.edu!ux1.cso.uiuc.edu!csrd.uiuc.edu!sp64.csrd.uiuc.edu!bliss From: bliss@sp64.csrd.uiuc.edu (Brian Bliss) Newsgroups: comp.lang.c Subject: Re: new style declarations OK for old style definitions? Message-ID: <1991Apr4.203418.1117@csrd.uiuc.edu> Date: 4 Apr 91 20:34:18 GMT References: <14590@life.ai.mit.edu> Sender: news@csrd.uiuc.edu (news) Reply-To: bliss@sp64.csrd.uiuc.edu (Brian Bliss) Organization: Center for Supercomputing Research and Development Lines: 40 In article <14590@life.ai.mit.edu>, 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? |> |> 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? It would certainly be desirable, since new-style |> declarations seem to allow for significant optimizations that aren't |> possible with old-style declarations. |> K&RII says (I'm reciting from memory, my book's at home): If a function which is declared new-style is called, and no prototype for it exists in the current scope, the promoted type of the actual argument must agree exactly with the unpromoted type of the formal argument. Since the compiler could not know whether the function was declared new-style or old-style (burp :-), it must use the same calling conventions for both. you are asking the converse, ig you can call an old-style function with a (new-style) prototype existing for it in the current scope, but I believe it is implicitly specified that using a prototype with promoted arguments is O.K. My question is why? just eliminate the prototype, or if you need the parameter type checking, change the definition of your function to be new-style, and change all of the formal arguments to their promoted types. Then you are following the ANSI standard to the letter. bb