The C–Pascal Interface
123
6
The
-calign
option is not needed for this example, but may be necessary if
the array parameter is an array of aggregates.
Conformant Arrays
For single-dimension conformant arrays, pass upper and lower bounds placed
after the declared parameter list. If the array is multidimensional, pass
element widths as well, one element width for each dimension, except the last
one. Chapter 8, “The FORTRAN–Pascal Interface,” has an example of
multidimensional conformant array passing.
The following example uses a single-dimension array:
The C function,
IntCA.c
void IntCA(int a[], int lb, int ub)
{
int k;
for (k=0; k <= ub - lb; k++)
a[k] = 4;
}
The Pascal main program,
IntCAMain.p
. Note that what
Pascal passes as
s
, is received
in C as
a
,
lb
,
ub
.
program IntCAMain(output);
var
s: array [1..3] of integer;
i: integer;
procedure IntCA(var a: array [lb..ub: integer] of integer);
external c;
begin
IntCA(s);
for i := 1 to 3 do
write(s[i]);
writeln
end. { IntCAMain }
Содержание SunSoft Pascal 4.0
Страница 14: ...xiv Pascal 4 0 User s Guide ...
Страница 16: ...xvi Pascal 4 0 User s Guide ...
Страница 30: ...6 Pascal 4 0 User s Guide 1 ...
Страница 160: ...136 Pascal 4 0 User s Guide 6 ...
Страница 268: ...244 Pascal 4 0 User s Guide 11 ...
Страница 320: ...296 Pascal 4 0 User s Guide B ...
Страница 331: ...Index 307 ...
Страница 333: ......