Reputation: 103
I have two units:
unit D8;
interface
uses Darbas;
const
Ilgis = 100;
type
Tmas = array[1..Ilgis] of integer;
and
unit Darbas;
interface
const
Ilgis = 100;
type
Tmas = array[1..Ilgis] of integer;
procedure Ieskoti(X:Tmas; m:byte; var nr:byte);
I do call procedure Ieskoti
in unit D8
button click event:
procedure TfrmD8.btn4Click(Sender: TObject);
var
nr : Byte;
begin
Ieskoti(A, n, nr); //HERE I GET ERROR
end;
and i do get error:
[dcc32 Error] D8.pas(130): E2010 Incompatible types: 'Darbas.Tmas' and 'D8.Tmas'
Upvotes: 3
Views: 1770
Reputation: 108929
Yes, this is how Delphi's type system works.
If you define two (static or dynamic) array types at two different places, they will not be assignment-compatible, even if they are "identical".
You need to define your type
type
Tmas = array[1..Ilgis] of Integer;
once and then refer to this type every time you need it.
For instance, you can choose to define it in Darbas
. Then remove the type definition from D8
and instead include Darbas
in D8
using a uses
clause, which you already do.
unit Darbas;
interface
const
Ilgis = 100;
type
Tmas = array[1..Ilgis] of Integer;
procedure Ieskoti(X: Tmas; m: Byte; var nr: Byte);
and
unit D8;
interface
uses Darbas;
Everything from the interface
section of Darbas
will now be visible in D8
, including the Ilgis
constant and the Tmas
type.
Upvotes: 5