[comp.os.vms] FORTRAN vs. C

LLACROIX@carleton.EDU (Les LaCroix) (04/15/88)

As long as everyone is on the topic of local variables and argument passing
in Fortran vs. C, here's a little quiz.  (I don't want a response, I already
know the answer.  At least for VMS 4.7, VAX C 2.3, and VAX Fortran 4.7.)

What do these programs output:

main.for:                           main.c:
        program main                  main() {
	integer i,j		      int i,j;
	do i=1,10		      for (i=1; i <= 10; ++i) {    
	    call fun(%val(1),j)	          fun(1,&j);
	    type *,j                      printf("%11d\n",j);
	end do                            }
	end                           }

when linked with the C function:

	fun(int k, int *j) {
	    *j = k++;
	}

Hint: although fun() is a legal C function, it violates
the VAX Procedure Calling and Condition Handling Standard.
-----------
Les LaCroix
SPSS Inc., 402 Washington, Northfield MN USA 55057-2027
507/663-1205
llacroix@carleton.edu  - or -  llacroix%carleton.edu@relay.cs.net
(CSnet)                        (BITNET -- don't know why the other one fails)