[fpc-devel] Forward Record

Amir Amir at Aavani.net
Thu Dec 5 00:50:35 CET 2024


Hi,

   I have a use-case where I needed to forward declare some records.
The FPC documentation 
<https://www.freepascal.org/docs-html/ref/refse16.html> says "Note that 
a forward type declaration is only possible with pointer types and 
classes, not with other types".

   I wonder why? Is there any technical difference between classes and 
records for the purpose of forward declaration?

My use-case was to define a few records like the following:

type
   TData = record
     ....
     function ToA: TA;
    end;

   TA = record
      Data: TData;
      ....
   end;

I know I can define classes instead of record, but I do not want to do 
so, since I need to "Free" the objects.

Amir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20241204/0e652ac4/attachment.htm>


More information about the fpc-devel mailing list