The way that the return value of a function is handled is very much like a
simple assignment statement. In practice, the value is actually returned in one
or two of the registers of the CPU, depending on the size of the data type.
Consequently there is no problem in handling the value of any function that
returns a numerical value as long as the storage used by the value being
returned and the value expected correspond
(see Table ).
If a VAX C function is treated as a LOGICAL function by VAX FORTRAN,
there is no problem as long as the VAX C function ensures that it returns a
value that will be interpreted correctly.
The best thing to do is to make sure that the C function can only return zero
(for false) or minus one (for true).
The case of a function that returns a character string is more complex. The way that VAX FORTRAN returns a CHARACTER variable as a function value is to add a hidden extra entry to the beginning of the argument list. This is a pointer to a character descriptor. If a VAX C function wishes to return a function value that VAX FORTRAN will interpret as a character string, then you must explicitly add an extra argument to the VAX C function and build the appropriate structure in your C function. This may seem rather complicated, but what it boils down to is that the following two segments of VAX FORTRAN are equivalent (but only in VAX FORTRAN).
CHARACTER*(10) RETURN CALL CHARFN( RETURN, A, B ) or CHARACTER*(10) RETURN, CHARFN RETURN = CHARFN( A, B )If written as a function, CHARFN returns a value of type CHARACTER. It is left as an exercise for the reader to demonstrate that the above assertion is true using just FORTRAN.
CNF and F77 Mixed Language Programming -- FORTRAN and C