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.
On 20 Dec 2000, at 17:41, nicolas bley wrote:
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)
[...]
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 }
I think that this is your problem. GPC has a built-in 'assign' procedure, which perhaps does some other things that your version does not do. Remove (or comment out) your own version, and things should be okay.
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku, PhD (The African Chief) Email: african_chief@bigfoot.com WWW: http://www.bigfoot.com/~african_chief
Prof. A Olowofoyeku (The African Chief) wrote:
On 20 Dec 2000, at 17:41, nicolas bley wrote:
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)
[...]
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 }
I think that this is your problem. GPC has a built-in 'assign' procedure, which perhaps does some other things that your version does not do. Remove (or comment out) your own version, and things should be okay.
I don't think that's the problem. In ancient GPC versions, it was recommended to use this Assign procedure. Since long, it has been built in, and the built-int version is mostly identical (it misses the last assignment which is pointless, and it sets B.Force := True which means that an invalid binding is "remembered" and causes a subsequent open to fail rather than open an internal file, so it's BP compatible). So now, it should work regardless whether this version is used or removed (and the built-in one is used).
I think the problem here is a linking problem, probably related to the use of this "strange" variety of modules and include files. I've never used them, and I don't really see their point, so I can't comment on the details... Are you using --automake, BTW?
Frank