Path: utzoo!utgpu!watmath!watdragon!lotus!jyegiguere From: jyegiguere@lotus.waterloo.edu (Eric Giguere) Newsgroups: comp.sys.amiga Subject: Re: Lattice C 5.0 Message-ID: <10497@watdragon.waterloo.edu> Date: 18 Dec 88 00:56:38 GMT References: <1427@cpoint.UUCP> Sender: daemon@watdragon.waterloo.edu Reply-To: jyegiguere@lotus.waterloo.edu (Eric Giguere) Organization: U. of Waterloo, Ontario Lines: 66 In article <1427@cpoint.UUCP> jeff@cpoint.UUCP (Jeffrey J. Griglack) writes: >I received my copy of Lattice C 5.0 yesterday and immediatly tried >it on some code I had written and compiled under 4.0. I got an >ERROR for a call to a function that did was not made in the form >of the function prototype. To correct this I had to cast the >perameter to a byte pointer (instead of a pointer of a type I had >defined myself). > >My problem is that I believe I should have just >gotten a WARNING instead of a hard error. Does the new ANSI >standard say that this should produce a warning or is it just >something peculiar to the Lattice implementation? I would think >that it would sometimes be nice to say, "Yes, I know I called it >wrong. I meant to." C was not supposed to be an idiot-proofed >(read "restrictive") language. I don't have the Standard in front of me, so I can't quote it, but the Standard says that if a function prototype is in scope, all parameters in a call to that function should be converted to agree with what the prototype declares. So if you say extern void foo( float ); foo( 1.0 ); it should implicitly convert the 1.0 (type double) to float. To me this implies that the compiler should not generate an error message. A warning makes more sense because it might catch any inadvertent conversions --- being able to turn the warning off would also be desirable. I don't have Lattice 5.0, so I can't comment on this, but I do hope that they've updated their function library to make the functions invariant to the default promotion vs. prototype conversion differences. In other words, the function putc should be defined as: int putc( int c, FILE *stream ) { /* etc */ } so that it works properly whether the full prototype is in scope or not. Otherwise if the first parm was defined as a char, the following code would be a problem: #ifdef PROTOTYPES extern int putc( char, STREAM * ); #endif void foo1( char c ) { putc( c, stdout ); } If PROTOTYPES is defined, the first parm will be passed to putc as a char. Otherwise, the default promotions will be used an c will be promoted to an int first..... This is something to watch out in your own code, too, especially if you are writing something to be portable between Lattice (prototypes) and Manx (no prototypes). -- --------------------------------------------------------------------------- Eric Giguere 268 Phillip St. #CL-46, Waterloo, Ont. N2L 6G9 jyegiguere@lotus.waterloo.edu (519) 746-0792 GIGUERE@WATCSG.BITNET "No, that's not how you pronounce it..."