7

The commands to compile and

execute DaysOfWeek.p and DaysOfWeekMain.cc without

the -calignoption

The commands to compile and execute DaysOfWeek.p and DaysOfWeekMain.cc withthe

-calign option

hostname% pc -c DaysOfWeek.p

hostname% CC DaysOfWeek.o DaysOfWeekMain.cc -lpchostname% a.out

Day = ''

hostname% pc -c -calign DaysOfWeek.p

hostname% CC DaysOfWeek.o DaysOfWeekMain.cc -lpc hostname% a.out

Day = 'Sunday'

Records and Structures

A Pascal record of an integer and a character string matches a C++ structure of the same constructs, as in this example:

The Pascal procedure, StruChr.p. It is safer for the Pascal procedure to explicitly provide the null byte and include it in the count before the string is passed to C++.

type

TLenStr = record

NBytes: integer;

ChrStr: array [0..24] of char; end;

procedure StruChr (

var v: TLenStr );

begin

v.NBytes := 14;

v.ChrStr := 'St.Petersburg' + chr(0); end;

146

Pascal 4.0 User’s Guide

Page 170
Image 170
HP SunSoft Pascal 4.0 manual calignoption, Hostname% pc -c DaysOfWeek.p, 146