HP SunSoft Pascal 4.0 Instrukcja Użytkownika Strona 117

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 333
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 116
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 }
Przeglądanie stron 116
1 2 ... 112 113 114 115 116 117 118 119 120 121 122 ... 332 333

Komentarze do niniejszej Instrukcji

Brak uwag