Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!convex!grogers From: grogers@convex.com (Geoffrey Rogers) Newsgroups: comp.lang.c Subject: Re: new style declarations OK for old style definitions? Message-ID: <1991Apr03.141849.26379@convex.com> Date: 3 Apr 91 14:18:49 GMT References: <14590@life.ai.mit.edu> Sender: news@convex.com (news access account) Organization: Convex Computer Corporation, Richardson, Tx. Lines: 39 Nntp-Posting-Host: mozart.convex.com In article <14590@life.ai.mit.edu> tmb@ai.mit.edu 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? Yes. If you don't use the default promotion types you will have problems. If you have a old-style definition of: int xyz(a,b,c) char a; short b; float c; { return 0; } The new-style declaration is: extern int xyz(int a, int b, double c); >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? Yes. If you said one thing and did another the compiler would have no way of known that you were lying to it, unless the new-style declaration was also in the same file as the old-style definition. +------------------------------------+---------------------------------+ | Geoffrey C. Rogers | "Whose brain did you get?" | | grogers@convex.com | "Abbie Normal!" | | {sun,uunet,uiucdcs}!convex!grogers | | +------------------------------------+---------------------------------+