Pascal intset type – HP SunSoft Pascal 4.0 User Manual

Page 135

Advertising
background image

The C–Pascal Interface

111

6

Pascal

intset

Type

The Pascal

intset

type is predefined as

set of [0..127]

. A variable of

this type takes 16 bytes of storage.

The Pascal procedure,

IntSetVar.p

, which has an

intset

of the elements

[1, 3, 7, 8]

procedure IntSetVar(var s: intset);

begin

s := [1, 3, 7, 8]

end; { IntSetVar }

The C main program,

IntSetVarMain.c

#include <stdio.h>

extern void IntSetVar(unsigned int *);

int main(void)

{

int w ;

unsigned int *p, *s ;

s = (unsigned int *) malloc(16);

IntSetVar(s) ;

for (w = 0, p = s ; w < 4 ; w++, p++)

printf("%012o %3d \n", *p, w);

printf(" 110 001 010 (binary, word 4) \n");

printf(" 876 543 210 (bits, word 4)" \n");

}

The commands to compile and
execute

IntSetVar.p

and

IntSetVarMain.c

. The

output of this example depends
on the architecture of your
machine.

hostname% pc -c IntSetVar.p

hostname% cc IntSetVar.o IntSetVarMain.c -lpc

hostname% a.out

000000000000 0

000000000000 1

000000000000 2

000000000612 3

110 001 010 (binary, word 4)

876 543 210 (bits, word 4)

Advertising