Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overloading a similar index type by declaring an array property 'Items' #141

Open
shineworld opened this issue Dec 16, 2024 · 1 comment

Comments

@shineworld
Copy link

With Athens the TList and other classes Items property is moved from Integer (32-bit on any platform) to NativeInt (32 or 64-bits, depend by platform).

In QuickLib, for example Quick.Threads.TThreadObjectList the property Items use Index: Integer, so during a 64-bit compilation a
warning message is shown:

[dcc64 Warning] Quick.Threads.pas(132): W1075 Overloading a similar index type by declaring an array property 'Items'
  Quick.Threads.pas(132): Related member: property TThreadObjectList<T>.Items[Integer]: T;
  Quick.Threads.pas(132): Related member: property TList<T>.Items[NativeInt]: T;
@shineworld
Copy link
Author

You can solve change any index from Integer to NativeInt or disabiling the warning in this way:

  {$IFNDEF FPC}
  {$IF (CompilerVersion > 36) or Declared(RTLVersion122)}{$WARN OVERLOADING_ARRAY_PROPERTY OFF}{$ENDIF}
  TThreadObjectList<T: class> = class(TList<T>)
    private
      fList: TObjectList<T>;
      fLock: TObject;
      fDuplicates: TDuplicates;
      function GetItem(aIndex : Integer) : T;
      procedure SetItem(aIndex : Integer; aValue : T);
    public
      constructor Create(OwnedObjects : Boolean);
      destructor Destroy; override;
      property Items[Index : Integer] : T read GetItem write SetItem ; default;
      procedure Add(const Item: T);
      procedure Clear;
      function LockList: TObjectList<T>;
      procedure Remove(const Item: T); inline;
      procedure RemoveItem(const Item: T; Direction: TDirection);
      procedure UnlockList; inline;
      property Duplicates: TDuplicates read fDuplicates write fDuplicates;
  end;
  {$IF (CompilerVersion > 36) or Declared(RTLVersion122)}{$WARN OVERLOADING_ARRAY_PROPERTY ON}{$ENDIF}
  {$ENDIF}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant