tomm@voodoo.UUCP (Tom Mackey) (08/12/87)
NOTICE: I am posting this for a friend of mine whose news software
is a bit brain damaged. Please respond to him, or follow this up,
but do not reply or respond to me. The path I use to get to John
Campbell, the author of this article, is:
Path to naucse: ssc-vax!uw-beaver!rutgers!hao!noao!arizona!naucse!jdc
Thanks...his article follows.
------------------cut here------------------------
Path: naucse!jdc
From: jdc@naucse.UUCP (John Campbell)
Newsgroups: comp.lang.c
Subject: current prototypes
Keywords: VMS 'C', 'C' prototypes
Message-ID: <372@naucse.UUCP>
Date: 3 Aug 87 03:33:26 GMT
Organization: Northern Arizona University, Flagstaff, Arizona
Lines: 58
>From the VMS Guide to VAX C manual (VMS 'C' version 2.3-024):
If the data type of an argument in a function call does not match
the prototype, VAX C attempts to perform conversions. If the
mismatched argument is assignment compatible with the prototype
parameter, VAX C converts the argument to the data type specified
in the prototype, according to the parameter and argument conversion
rules (...).
If the mismatched argument is not assignment compatible with the
prototype parameter, the action generates the appropriate error
message and the results are undefined.
Here is a listing (with /MACHINE interspersed) of a program that compiles
without any complaints:
1
2 void farm_it (int aa, char **bb);
3 main()
4 {
main:
.entry main,^m<r2,r3>
subl2 #4,sp
jsb C$MAIN
5 1 int a;
6 1 float b;
7 1
8 1 farm_it (a, b);
cvtfl r2,-(sp)
pushl r3
calls #2,FARM_IT
9 1 }
movl #1,r0
ret
10
11 void farm_it (a, b)
12 int a;
farm_it:
.entry farm_it,^m<>
subl2 #4,sp
13 float b;
14 {
15 1 b = a;
cvtld 4(ap),8(ap)
16 1 }
ret
Changing the definition of farm_it to use the new style function
definition with this compiler (eg void farm_it (int a, float b) {})
will cause the compiler to give an error message about mismatched
arguments.
Questions:
Should old and new style definitions yield different behaviors?
Is this the expected way to implement prototypes?
Are prototypes all that useful in such an implementation?
Is it really correct to CVTFL in the guise of "assignment compatibility"?
------------------cut here-------------------------
--
Tom Mackey (206) 656-7724 (wk)
Boeing Computer Services ....uw-beaver!ssc-vax!voodoo!tomm
M/S 6M-17, P.O. Box 24346, Seattle, WA 98124-0346