[fpc-pascal] No type info available for this type (Enumerated type with constant assignment)

Michael Van Canneyt michael at freepascal.org
Mon Jul 23 12:41:36 CEST 2018



On Mon, 23 Jul 2018, Dennis wrote:

> I am trying out the examples at 
> http://wiki.freepascal.org/Enumerated_types but
> The following simple program will raise compiler error "No type info 
> available for this typ"
>
> I am using Lazarus 1.8.0  FPC 3.0.4   x86_64-Win64-win32/win64
>
>
> program testenum;
> uses typinfo, classes, sysutils;
> type
>   TMonthType = (January=1, February, May=5,June, July);
>
> var i : int32;
>     s : String;
> begin
>   for i := Ord(Low(TMonthType)) to Ord(High(TMonthType)) do
>     begin
>        s:= GetEnumName(TypeInfo(TMonthType), Ord(i)); <- compiler error 
> pointed at the word TypeInfo
>        Writeln(i.ToSTring+' -> '+s);
>     end;
>   readln;
> end.
>
>
>
> However, if I change to
>   TMonthType = (January, February, May,June, July);
>
> The compiler error will disappear.
>
> Is this kind of enumerated type with constant assignment not supported 
> by FPC 3.0.4?
>
>   TMonthType = (January=1, February, May=5,June, July);

No, only normal enumerated types can be used like that.

Michael.


More information about the fpc-pascal mailing list