[fpc-pascal] rtl-generics: TIStringComparer.Ordinal -> Access violation

silvioprog silvioprog at gmail.com
Wed Aug 17 18:45:58 CEST 2016


On Wed, Aug 17, 2016 at 12:20 PM, Maciej Izak <hnb.code at gmail.com> wrote:

>
> 2016-08-17 16:05 GMT+02:00 silvioprog <silvioprog at gmail.com>:
>
>> I need to find the values using case-insensitive keys (I'm using it in a
>> class registry of my app), so unfortunately this bug doesn't let me to use
>> TDictionary on FPC yet. :-(
>
>
> There is simple workaround:
>
> === begin code ===
>
> function EqualityComparison(constref ALeft, ARight: string): Boolean;
> begin
>   Result := LowerCase(ALeft) = LowerCase(ARight);
> end;
>
> procedure ExtendedHasher(constref AValue: string; AHashList: PUInt32);
> begin
>   TDefaultHashFactory.GetHashList(Pointer(AValue), Length(AValue) *
> SizeOf(Char), AHashList);
> end;
>
> var
>   list: TDictionary<string, string>;
> begin
>   list := TDictionary<string, string>.Create(TEqualityCompar
> er<string>.Construct(EqualityComparison, ExtendedHasher));
>
> === end code ===
>

I changed it to a function:

  function ExtendedHasher(constref AValue: string): UInt32;
  begin
    TDefaultHashFactory.GetHashList(Pointer(AValue),
      Length(AValue) * SizeOf(Char), @Result);
  end;

because the "Error: Incompatible type for arg no. 2: Got
"ExtendedHasher(constref AnsiString;PDWord);", expected "<procedure
variable type of function(constref AnsiString):DWord;Register>"".

Anyway, thanks for the workaround, it can fix the FPC version of my tests.
:-)

--
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160817/e415548d/attachment.html>


More information about the fpc-pascal mailing list