[fpc-pascal] How to get the offset of a record

Ludo Brands ludo.brands at free.fr
Sat Apr 30 16:50:56 CEST 2011


This is ages ago, but IIRC getmem would allocate memory on segment
boundaries (offset 0). In a dynamically allocated record ofs(record.member)
(one f) would give you the offset to the start of record. This was obviously
a special case. I'm not sure if large/huge memory model was part of it.
Otherwise, conceptually, I can't imagine a function that would return an
offset to the start of a structure by only giving a reference to a member of
that structure. Even Florians solution contains the starting point: nil.

Ludo

-----Message d'origine-----
De : fpc-pascal-bounces at lists.freepascal.org
[mailto:fpc-pascal-bounces at lists.freepascal.org] De la part de Jonas Maebe
Envoyé : samedi 30 avril 2011 15:28
À : FPC-Pascal users discussions
Objet : Re: [fpc-pascal] How to get the offset of a record



On 30 Apr 2011, at 15:20, Rainer Stratmann wrote:

> Am Saturday 30 April 2011 15:16:08 schrieb Jonas Maebe:
>> That's incorrect. In TP, Ofs(recvar.var1) (with one "f") returns the 
>> offset in the segment that contains the "recvar" variable. It does 
>> not return the relative offset of the field inside the record type.
> 
> That are 2 different things.
> 
> There was a function which gives the relative offset of the field I am 
> very
> sure of that. And I am very sure that it was offs (wich 2 "f").

I'm quite sure it's not, see attachment. The only thing that existed was the
"offset" operator, but it only worked in assembler blocks (and afaik it also
works in FPC assembler blocks).


Jonas





More information about the fpc-pascal mailing list