Wak 1 Posted July 11 I've worked with generics quite a bit, but I have never tried to define a generic pointer type to another generic type: TMyType<T> = record ID: T; end; PMyType<T> = ^TMyType<T>; // Error: E2508 type parameters not allowed on this type TMyTypes<T> = array of TMyType<T>; // OK PMyTypes<T> = array of ^TMyType<T>; // OK TMyTypeHack<T> = record P: ^TMyType<T>; // OK end; This raises a compiler error. It seems Delphi doesn't allow type aliases like this, but allows using them in the definition of array/record types. Has anyone found a trick to achieve it? Thanks! Share this post Link to post
pmcgee 27 Posted August 4 I feel like I seen this somewhere .. maybe even from Marco Cantu .. mentioning that this "hack" was necessary. PMyType<T> = record P: ^TMyType<T>; end; Share this post Link to post
pmcgee 27 Posted August 4 Looks like it was here : https://stackoverflow.com/questions/5344433/how-can-i-declare-a-pointer-based-on-a-generic-type Share this post Link to post