![](/images/backgrounds/286549/hp-sunsoft-pascal-4-0-users-manual-549395185x1.png)
7
Global Variables in C++ and Pascal
The Pascal procedure, GloVar.p
The C++ main program, GloVarMain.cc
If the types are compatible, a global variable can be shared between C++ and Pascal. See this example:
var
Year: integer;
procedure GloVar;
begin
Year := 1995; end;
#include <stdio.h>
extern "C" void GloVar ();
int Year;
int main(void)
{
Year = 2042;
GloVar ();
printf (" %d \n", Year);
}
The commands to compile and execute GloVar.p and GloVarMain.cc
hostname% pc
hostname% CC GloVar.o GloVarMain.cc
1995
The | 161 |