Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site hoptoad.uucp Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!sun!hoptoad!gnu From: gnu@hoptoad.uucp (John Gilmore) Newsgroups: net.lang.c Subject: Help me out on Float Double Parameters Message-ID: <667@hoptoad.uucp> Date: Wed, 9-Apr-86 04:53:07 EST Article-I.D.: hoptoad.667 Posted: Wed Apr 9 04:53:07 1986 Date-Received: Fri, 11-Apr-86 00:47:49 EST References: <2600042@ccvaxa> <5216@alice.uUCp> <2442@utcsri.UUCP> <3439@sun.uucp> Organization: Nebula Consultants in San Francisco Lines: 49 In article <3439@sun.uucp>, guy@sun.uucp (Guy Harris) writes: > Mr. Koenig is correct. According to the August 11, 1985, X3J11 draft: > > C3.2.2 Function calls > > ... Also, *if no function prototype declarator is in scope*, the > integral promotions are performed and arguments that have type > "float" are promoted to "double". ("italics" mine) > > ... If a function prototype declarator is in scope, the arguments > are compared with the formal parameters. ...The types must be > such that each formal parameter may be initialized by the > coresponding argument, and the arguments are converted > accordingly. I think the above applies to CALLS of the function, not DEFINITIONS of the function. But let me see if I understand how this works. If I write: foo(float x) {...} /* DEFINE */ then (if this is legal, which I don't know) it expects it as float. (Of course, any time the DEFINITION expects float, there had better be a DECLARATION in the callers' routines that matches.) foo(x) float x; {...} /* DEFINE */ I presume for compatability it must expect double. foo(float x); /* DECLARE */ foo(x) float x; {...} /* DEFINE */ Now maybe it can expect float? Suppose the declaration and the definition are separated by a few pages, or the declaration is in a header file -- how will you know what the routine expects? foo(float x) float x; {...} /* DEFINE */ Is this legal? Does it take float or double? Is the same true if you declare an argument char or short? Does it avoid the widening to int on the stack? I can see that no matter what the answers to the above questions, the C standardization process is not making C any simpler to use. Sigh. Feeping creatureism is leaving its trail of turds. -- John Gilmore {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu jgilmore@lll-crg.arpa Post no bills.