HP SunSoft Pascal 4.0 User Manual
Page 133
Advertising
The C–Pascal Interface
109
6
The C main program,
VarRecMain.c
#include <stdio.h>
struct vlr {
char tag;
union {
struct {
char ch1, ch2;
}a_var;
struct {
char flag;
}b_var;
struct {
int ALIGN;
}c_var;
}var_part;
};
extern void VarRec(struct vlr *);
int main(void)
{
struct vlr *x;
x = (struct vlr *)malloc(sizeof(struct vlr));
x->tag = 'a';
x->var_part.a_var.ch1 = 'a';
x->var_part.a_var.ch2 = 'b';
VarRec(x);
printf(" %c \n", x->var_part.a_var.ch2);
}
The commands to compile and
execute
VarRec.p
and
VarRecMain.c
hostname% pc -c -calign VarRec.p
hostname% cc VarRec.o VarRecMain.c -lpc
hostname% a.out
Z
Advertising