[fpc-devel] Gaps in a non-contiguous enum
Martin Frb
lazarus at mfriebe.de
Thu Aug 11 15:37:26 CEST 2022
On 11/08/2022 13:38, Juha Manninen via fpc-devel wrote:
>
> // An empty string and the enum's unit name happen in gaps
> // of a non-contiguous enum. Why the unit name? A bug in FPC code?
> with GetTypeData(EnumType)^ do
> for I := MinValue to MaxValue do begin
> s := GetEnumName(EnumType, I);
Because you are not supposed to use MaxValue
Instead use GetEnumNameCount
for I := MinValue to MinValue + GetEnumNameCount(...) - 1 do begin
The unit name is returned because the TypeDate stores the unitname after
the continuous list of element names. And once you are out of index ...
More information about the fpc-devel
mailing list