Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!att!dptg!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c Subject: Re: prototype my function, please... Keywords: prototype Message-ID: <10848@alice.UUCP> Date: 21 May 90 21:43:10 GMT References: <1231@wet.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 49 In article <1231@wet.UUCP>, noah@wet.UUCP (Noah Spurrier) writes: > I get the bad feeling that I am going to get flamed for this... But I can > see no reason why my Turbo C compiler does not like the way I prototype > the following program. > /* Protoypte */ > void x (float); /* ... */ > void x (y) > float y; > { > printf ("%f",y); > } You should do it this way: void x(float y) { printf("%f",y); } The point is that old-style parameter declarations are decidedly not equivalent to new-style declarations. For compatibility reasons, it must be legal to define void x(y) float y; { /* ... */ } and call it from a separately compiled module without any declaration there at all. That means it must be capable of accepting a double parameter. Thus, in effect, this least example is equivalent to: void x(double dummy) { float y = dummy; /* ... */ } In other words, if you want to use ANSI-style function prototypes, you must use them consistently. -- --Andrew Koenig ark@europa.att.com