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
Summary of Contents for SunSoft Pascal 4.0
Page 14: ...xiv Pascal 4 0 User s Guide ...
Page 16: ...xvi Pascal 4 0 User s Guide ...
Page 30: ...6 Pascal 4 0 User s Guide 1 ...
Page 160: ...136 Pascal 4 0 User s Guide 6 ...
Page 268: ...244 Pascal 4 0 User s Guide 11 ...
Page 320: ...296 Pascal 4 0 User s Guide B ...
Page 331: ...Index 307 ...
Page 333: ......