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

  • 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 131
108 Pascal 4.0 Users Guide
6
When you compile the Pascal routine without using the -calign option, the
program does not work correctly.
Variant Records
C equivalents of variant records can sometimes be constructed, although there
is some variation with architecture and sometimes a need to adjust alignment.
You can avoid the need to adjust alignment by using the -calign option.
The commands to compile and
execute DayWeather.p and
DayWeatherMain.c
without
-calign
hostname% pc -c DayWeather.p
hostname% cc DayWeather.o DayWeatherMain.c -lpc
hostname% a.out
day = ''
weather = ' sun'
The commands to compile and
execute DayWeather.p and
DayWeatherMain.c
with
-calign
hostname% pc -calign -c DayWeather.p
hostname% cc DayWeather.o DayWeatherMain.c -lpc
hostname% a.out
day = 'Sunday'
weather = 'sunny'
The Pascal procedure,
VarRec.p
type
vr = record
case tag: char of
'a': (ch1, ch2: char);
'b': (flag: boolean);
'K': (ALIGN: integer);
end;
procedure VarRec(var x: vr);
begin
if x.ch1 = 'a' then
x.ch2 := 'Z'
end; { VarRec }
Zobrazit stránku 131
1 2 ... 127 128 129 130 131 132 133 134 135 136 137 ... 332 333

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

Žádné komentáře