[fpc-pascal] Empty record inside another record ?
Skybuck Flying
skybuck2000 at hotmail.com
Fri Feb 15 23:26:54 CET 2008
To me it seems like some kind of trick, to extend a record at runtime.
The empty record field, functions as a sort of offset/label/pointer if you
will to the new fields that will will be extended to the record by simply
allocating more memory then the size of the record.
Then this "label"/"field" can be used as a sort of offset, by typecasting it
to some extension record type.
Could be pretty handy, quite impressive trick.
However, is it safe to use ?
I cannot find anything in the documentation about this ?
Seems to be an old trick as well.
Gonna copy this stuff and ask on free pascal compiler list, maybe they know
something about this ;) I wonder if free pascal supports this trick as well
;)
Bye,
Skybuck.
"Skybuck Flying" <spam at hotmail.com> wrote in message
news:83db1$47b60dc9$541983fa$8366 at cache6.tilbu1.nb.home.nl...
> Hello,
>
> What's going on here:
>
> type
> TsomeRecord = record
> SomeField : integer;
> SomeEmptyRecord : record end;
> end;
>
> How can SomeEmptyRecord be usefully used ?
>
> What is it ?
>
> SizeOf(TsomeRecord) returns 4, kinda weird ?!
>
> Bye,
> Skybuck.
>
>
More information about the fpc-pascal
mailing list