I have found a couple of apparent bugs in GPC:
1. Debugger and objects. ------------------------------
There appears to be an error in debug entries generated for objects. When viewing object fields under the debugger, the wrong values are shown for the right field.
If I set a breakpoint at the end of the constructor and examine *Self, I get
*Self: {One = 74404, Two = 1, Three = 2}
program bad;
type MyObject = object One : Integer; Two : Integer; Three : Integer; constructor init; end; var x : MyObject;
constructor MyObject.init; begin One := 1; Two := 2; Three := 3; end;
begin x.init; end.
Direct Access Files -----------------------
There appears to be some discrepancy between record numbering for reading and writing. To read record n, I specify SeekRead(n). But to write record n, I specify SeekWrite(n). When I execute the following program, I get:
Created File 0 : 0 1 : 1 2 : 2 3 : 3 4 : 4 5 : 5 Modified file at position 0 to 55 Modified file at position 2 to 66 Modified file at position 6 to 77 0 : 0 1 : 66 2 : 2 3 : 3 4 : 4 5 : 77
PROGRAM Bad1;
TYPE DAFile = File [0..5] of Integer; VAR MyFile : bindable DAFile;
procedure AssignFile; var b : BindingType; begin unbind(MyFile); b := binding(MyFile); b.name := 'test.dat' + chr(0); bind(MyFile,b); end;
procedure CreateFile; var i : Integer; begin AssignFile; Rewrite(MyFile); for i := 0 to 5 do Write(MyFile,i); Close(MyFile); end;
procedure ModifyFile(index : Integer; val : Integer); var pos : Integer; begin AssignFile; SeekWrite(MyFile,Index); pos := Position(MyFile); Write(MyFile,val); Close(MyFile); Writeln('Modified file at position ',pos,' to ',val); end;
procedure PrintFile; var i,val,pos : Integer; begin AssignFile; for i := 0 to 5 do begin SeekRead(MyFile,i); pos := Position(MyFile); Read(MyFile,val); WRITELN(pos,' : ',val); end; Close(MyFile); end;
begin CreateFile; WRITELN('Created File'); PrintFile; ModifyFile(0,55); ModifyFile(2,66); ModifyFile(6,77); PrintFile; end.
TurboVision ---------------
I was surprised to see that the Turbo Vision source code is in C++ and I see that Turbo Vision is still in the TO DO list for GPC.
Whats the current situation?
I presume that GPC can't access Gnu C++ classes. Therefore someone needs to either write a wrapper or to convert the C++ classes into PASCAL objects.
Is anyone currently working on a port?
Turbo Vision is fairly important to me so I'd be interested porting it to GPC.
Russell Thamm
Hello!
Russell Thamm wrote:
There appears to be an error in debug entries generated for objects. When viewing object fields under the debugger, the wrong values are shown for the right field.
I suspect that GPC did not output debugging information for the implicit VMT field in the object. Anybody out there who knows more about how the generation of debugging information in the GNU compiler works?
I was surprised to see that the Turbo Vision source code is in C++ and I see that Turbo Vision is still in the TO DO list for GPC.
Whats the current situation?
We have free Pascal sources of a TV-compatible library that cries to be ported to GPC. Once we asked at this list for volunteers eager to contribute to this project but got no reaction.
I presume that GPC can't access Gnu C++ classes.
Correct. :-(
Turbo Vision is fairly important to me so I'd be interested porting it to GPC.
This is your chance. ;-)
Frank Heckenbach wrote:
You terminate the file name with a chr (0). That's not only unnecessary (because the Name field of BindingType is a Pascal string, not a CString), but also potentially problematic: [...]
This is true now (since gpc-2.0). With gpc-1.x, it was necessary to append chr(0) explicitly to work around a bug in the GPC run time system. Some outdated documentation might still contain the workaround.
Greetings,
Peter