[fpc-pascal] TypeInfo on generic templates
Sven Barth
pascaldragon at googlemail.com
Fri Oct 30 07:44:34 CET 2020
Am 29.10.2020 um 19:27 schrieb Ryan Joseph via fpc-pascal:
> Is it possible that the TypeInfo intrinsic could work with generic template types or is this a bug? I get "Illegal qualifier" in the procedure below.
>
> generic procedure DoThis<T>(a: array of T);
> begin
> writeln(TypeInfo(T)^.name);
> end;
This would fail with a non-generic as well, because the TypeInfo()
intrinsic returns a plain Pointer. You need to cast it to PTypeInfo (and
obviously the unit TypInfo needs to be used):
PTypeInfo(TypeInfo(T))^.Name
Regards,
Sven
More information about the fpc-pascal
mailing list