HP SunSoft Pascal 4.0 Uživatelský manuál Strana 169

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 333
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 168
The C++–Pascal Interface 145
7
Although it does not apply to this example, arrays of aggregates in Pascal
have, by default, a size that is a multiple of four bytes. When you use the
-calign option to compile Pascal code, that difference from C++ is
eliminated.
The following example illustrates this point. The string 'Sunday' only gets
through to the C++ main program when you compile the Pascal routine using
the -calign option.
The Pascal procedure,
DaysOfWeek.p
type
TDay = array [0..8] of char;
TWeek = array [0..6] of TDay;
TYear = array [0..51] of TWeek;
procedure DaysOfWeek (
var Y: TYear
);
begin
Y[1][1] := 'Sunday';
end;
The C++ main program,
DaysOfWeekMain.cc
#include <stdio.h>
extern "C" void DaysOfWeek (
char [52][7][9]);
int main(void)
{
char Year [52][7][9];
DaysOfWeek (Year);
printf (" Day = '%s' \n", Year[1][1]);
}
Zobrazit stránku 168
1 2 ... 164 165 166 167 168 169 170 171 172 173 174 ... 332 333

Komentáře k této Příručce

Žádné komentáře