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
Содержание SunSoft Pascal 4.0
Страница 14: ...xiv Pascal 4 0 User s Guide ...
Страница 16: ...xvi Pascal 4 0 User s Guide ...
Страница 30: ...6 Pascal 4 0 User s Guide 1 ...
Страница 160: ...136 Pascal 4 0 User s Guide 6 ...
Страница 268: ...244 Pascal 4 0 User s Guide 11 ...
Страница 320: ...296 Pascal 4 0 User s Guide B ...
Страница 331: ...Index 307 ...
Страница 333: ......