Float Double Parameters
kwh at bentley.UUCP
kwh at bentley.UUCP
Sat Mar 29 06:17:23 AEST 1986
In article <2600042 at ccvaxa> ccvaxa!aglew writes:
>X3J11 says "arguments that have type float are promoted to double". Too bad.
I don't know anything about X3J11, but I thought ANSI C would allow the
declaration of arguments of extern functions, and would honor "float" if
so declared (but would continue to promote float to double for wild-card
arguments).
>Here is der Mouse's letter...
>> foo(r) float r; { ... }
My own feeling is that it is WRONG to declare a float argument. Since the
language automatically promotes (which I agree is poor design, though I
understand the reasons behind it), the variable "r" cannot possibly be a
float. The compiler is being "nice" by letting you get away with it (it
"knows" that floats can't be passed by value, so it treats it as a double
declaration instead). I think it should get a warning at least.
Similarly, I never declare a formal parameter as an array (e.g. char *argv[]).
It may very well be the name of an array that was passed by the caller, but
since it's automatically converted to a pointer, I prefer to declare the
formal as a pointer rather than letting the compiler translate the declaration
for me. (Also, I could swear I once used a compiler that didn't treat arrays
and pointers identically as formal parameters.)
Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint
More information about the Comp.lang.c
mailing list