Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!fluke!ssc-vax!voodoo!tomm From: tomm@voodoo.UUCP (Tom Mackey) Newsgroups: comp.lang.c Subject: current prototypes Message-ID: <393@voodoo.UUCP> Date: Tue, 11-Aug-87 17:32:39 EDT Article-I.D.: voodoo.393 Posted: Tue Aug 11 17:32:39 1987 Date-Received: Sat, 15-Aug-87 08:33:54 EDT Reply-To: tomm@voodoo.UUCP (Tom Mackey) Distribution: world Organization: Voodoo Graphics Project Lines: 92 Keywords: VMS, C, C prtotypes 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 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