The C–Pascal Interface
93
6
Pascal Set Types
In Pascal, a set type is implemented as a bit vector, which is similar to a C
short-word array, where each short-word contains two bytes. Thus, sets are
bit-vectors, and they are allocated in multiples of 16 bits. To find out the size
of a set, enter the following code:
Direct access to individual elements of a set is highly machine-dependent and
should be avoided.
General Parameter Passing in C and Pascal
A few general rules apply to parameter passing:
•
C passes all arrays by reference since C strings are arrays.
•
C passes all structures by value.
•
In C, if you want to pass anything else by reference, then you must
explicitly prepend the reference ampersand (
&
), or pass an explicit pointer.
•
Pascal passes all parameters by value unless you explicitly state that they
are
var
,
in out
, or
out
parameters, in which case they are passed by
reference.
Procedure Calls: C–Pascal
Here are examples of how a C main program calls a Pascal procedure:
ceiling( ord(
highest_element
) / 16 )
The Pascal procedure,
Samp
, in
the file
Samp.p
. Note the
procedure definition.
procedure Samp(var i: integer; var r: real);
begin
i := 9;
r := 9.9
end; { Samp }
Содержание 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: ......