Calling Dil Routines From Fortran - HP 9000 Series 300 Tutorials Manual

Device i/o and user interfacing hp-ux concepts and tutorials
Hide thumbs Also See for HP 9000 Series 300:
Table of Contents

Advertisement

The equivalent external declaration for the same subroutine in a Pascal
program is:
TYPE
PATHNAME
=
PACKED ARRAY [0 .. 50] OF CHAR;
FUNCTION open
(VAR path: PATHNAME;
of lag: INTEGER):
INTEGER;
EXTERNAL;
Note that the path parameter is a
VAR
parameter, indicating that the
parameter is passed by reference. This simulates the passing of a pointer,
which is what open(2) expects. In general, declaring a C routine from Pascal is
straightforward.
Calling
OIL
Routines from FORTRAN
C and FORTRAN subroutine calls are not compatible because C passes
parameters by value while FORTRAN passes them by reference. This
incompatibility can be easily circumvented by directing the compiler to
generate a call by value through the use of FORTRAN's $ALIAS option. For
example:
$ALIAS close
=
'close' (%val)
If the FORTRAN compiler on your system does not support this form of
$ALIAS, the parameter-passing differences can be resolved by writing an
onionskin routine which is a C-language function written for the purpose of
resolving parameter-passing irregularities between C and other languages.
For example, to access close(2) through an onionskin routine, use:
$ALIAS close
=
'_my_io_close'
then write the onionskin routine:
int my_io_close (eid)
1*
the compiler will create the external symbol "_my_io_close"
based on the above declaration*/
int *eid;
{
return (close (*eid»;
}
1-4
Interfacing Concepts

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Hp 9000 series 800

Table of Contents