Xref: utzoo comp.std.c:4351 comp.sys.amiga.programmer:969 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!munnari.oz.au!mel.dit.csiro.au!yarra!pta!teti!teslab!andrew From: andrew@teslab.lab.OZ (Andrew Phillips) Newsgroups: comp.std.c,comp.sys.amiga.programmer Subject: Re: ANSI prototypes, the right choice... Summary: Problem is float/short/char in prototypes + old style func defns Message-ID: <1205@teslab.lab.OZ> Date: 19 Feb 91 06:38:05 GMT References: <7708@sugar.hackercorp.com> <15089@smoke.brl.mil> <1991Feb9.075215.26939@athena.mit.edu> <1991Feb11.030811.25074@sugar.hackercorp.com> Reply-To: andrew@teslab.lab.oz.au (Andrew Phillips) Organization: minimal Lines: 32 In article <1991Feb11.030811.25074@sugar.hackercorp.com> peter@sugar.hackercorp.com (Peter da Silva) writes: >You have it backwards. Lattice accepts mixtures. No other Ansi-compatible >compiler I've used does... It depends on what you mean by "mixtures". If you mean using float, short or char in prototypes and old style function definitions, ie: double f(float x); double f(x) float(x); { ... } then this would be a big problem and I would expect any ANSI compiler which found these in the same source file to generate an error. If Lattice 5.10 does this then this is very bad, since the caller is going to pass a float and the callee expects a double. HOWEVER, I know that a lot of ANSI draft compilers, which had prototypes but came out before the ANSI new style function definitions were invented allowed this (but the caller would pass x as a double so it was OK). Examples are older Lattice compilers (4.0?) and Microsoft C 4.0 (MSDOS) and many UNIX compilers for a long time. So this is definitely a problem to look out for if you are compiling old code (esp. if the prototype does not appear in the same source file as the function defn). OF COURSE, all new code should be written using prototypes and the new style function definitions. But mixing old and new is OK if you avoid float, short and char in prototypes. Andrew. -- Andrew Phillips (andrew@teslab.lab.oz.au) Phone +61 (Aust) 2 (Sydney) 289 8712