On 13 Aug 2011, at 12:28, Juha Manninen wrote:

> TMainMenu.Items is of type TMenuItem. TMenuItem has only one version of
> "Add" method and it takes another TMenuItem as parameter (checked from VCL
> source).
> Still, to my surprise, the code works in Delphi.
> 
> FPC says: Error: Incompatible type for arg no. 1: Got "Dynamic Array Of
> TMenuItem", expected "TMenuItem"
> which is what I expected also from Delphi.

It is always best to isolate such things in a self-contained example that does 
not depend on external code. Does this compile with your Delphi version?

***
type
  tc = class
  end;

procedure add(c: tc);
begin
end;

var
  a: array of tc;
begin
  add(a);
end.
***

If not, the issue is something else. It seems more likely to me that there is 
somewhere another "add" method that Delphi picks up but FPC doesn't. E.g., 
there is at least also "TComponent.Add(item : IUnknown) : Integer;". While that 
one won't accept a dynamic array, maybe Delphi 2009 has more add methods in 
TComponent declared with "overload" (although normally searching for overloads 
should stop as soon as a method is found in a class without "overload", so in 
principle the search should stop when tmenuitem.add is encountered).

If the above does compile, what does it actually do? Pass the first element of 
the array?


Jonas_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to