[fpc-pascal]pointers under linux

Shifted Soul snsii at yahoo.fr
Fri Mar 15 09:35:50 CET 2002


Hello
I get for you some troubles.
Lately I developped a unit which function perfectly under go32 and not
under linux. But I didn't use any specific instruction for a given
platform.
So I debugged it under linux, and I found where the problem.
But why it works under go32 and not under linux.
I give you a sample program which don't work under linux :

{$MODE OBJFPC}
{$H+}
type
  t = ^trec;
  trec = record
    s : string;
    n : t;
  end;

var
  t1 : t;

begin
  new(t1);
  t1^.s := 'hello';
  t1^.n := Nil;
  new(t1^.n);
  t1^.n^.s := 'Hello2';
end.

It will give me RT Error 216 (in the unit, where I use classes, it is
Access Violation exception).
gdb told me that it stops at the instruction
_SYSLINUX$$_INITIALIZE$POINTER$POINTER
The problem araises only in these conditions :
+ $H+ enabled
+ chained list
+ initialize the next item by nil (t1^.n := Nil;)
+ create it by new (new(t1^.n);)
it stops then.
I have the solution for the problem :
create the next item seperately and link it :

new(p);
t1^.n := p;

but I want to know why we can't use the first way ?
Sorry for the problem.

NB : I use fpc 1.0.4 under linux RPM version, I will use the next
version when i complete downloading it (I have a modem with 4kB/s)






More information about the fpc-pascal mailing list