
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 }
Commenti su questo manuale