We currently face a problem porting pascal Oregon programs on GPC.
These programs use files descriptors declared as global variables.
These descriptors are declared in a module while they are used in
another module.
Trying to open one of these files in write mode (rewrite function), we
get a strange error message:
?GPC runtime error: (gpc-rts) _p_initfdr() has not been called for file
(#701)
Does someone know how to manage file descriptors declared as global
variables?
(See included files for example).
#ifndef VARIABLE
#define VARIABLE
module Variable interface;
export Variable = ( GlobalFile,FileType );
type
FileType = file of char;
var
GlobalFile : FileType;
end.
#endif
#include "variable.ph"
module Variable implementation;
var GlobalFile : FileType;
end.
#include "variable.ph"
program file_test;
import variable;
var
Filename : string(20);
procedure assign( var t : FileType; var name : string );
var b : Bindingtype;
begin { assign }
unbind( t );
b := binding( t );
b.name := name;
bind( t, b );
b := binding( t );
end; { assign }
begin
Filename :='toto.txt';
assign(GlobalFile,Filename);
rewrite(GlobalFile);
end.