CALLC - call a C function from a Fortran 66 routine.

Alternate Entry Name: .CALLC

Usage:

external cfunc
integer callc
...
i = callc(cfunc, arg1, arg2, ...)

Where:

cfunc
is the name of a C function.
arg1, arg2, ...
are arguments to be passed to the C function.

Description:

CALLC will call the C routine "cfunc" with arguments "arg1", "arg2", etc.

When Fortran 66 calls a routine, it always does so by passing pointers to the actual arguments. Thus the C function which is called must indirect through the pointers it receives in order to get the actual values. For example, "*(arg1)" would give the contents of the first argument passed by the Fortran program.

CALLC is very similar to CALLB except that it generates C style pointers. That is, the address is in the upper 18 bits of the argument word.

The value returned by CALLC is the result of "cfunc". If "cfunc" does not return a value, the "integer" declaration may be omitted and CALLC may be invoked as a subroutine via the Fortran "call" statement. Similarly, if "cfunc" is a function returning "float" or "double", the "integer" declaration would be replaced with a "real" or "double precision" declaration.

Any Fortran program using CALLC must be loaded using the B run-time library or else the stack will not be properly constucted to handle the B function. Note that the Pascal and C run-time libraries include the C run-time library.

See Also:

expl b fortran
for a general discussion about Fortran within a B environment.
expl b lib callb
for a similar routine to call a B routine from Fortran.
expl b lib callf
for how to call a Fortran routine from B, C or Pascal.
expl b lib callff
for how to call a Fortran REAL function from B.

Copyright © 1996, Thinkage Ltd.