[fpc-pascal]pointers under linux
snsii at yahoo.fr
Fri Mar 15 09:35:50 CET 2002
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
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 :
t = ^trec;
trec = record
s : string;
n : t;
t1 : t;
t1^.s := 'hello';
t1^.n := Nil;
t1^.n^.s := 'Hello2';
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
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 :
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