Reputation: 1339
I am constantly getting the: Undeclared identifier for an interface type I have defined in another unit. Here is what I have:
unit Drawers;
interface
implementation
type
IDrawer = interface
['{070B4742-89C6-4A69-80E2-9441F170F876}']
procedure Draw();
end;
end.
unit Field;
interface
uses
Graphics, Classes, Drawers;
TField = class(TInterfacedObject, IField)
private
FSymbolDrawer: IDrawer;
At FSymbolDrawer I get the complier error.
Of course I have the uses Drawers; in the unit where TField is defined.
What's this about?
Thank you
Upvotes: 3
Views: 686
Reputation: 2453
In the unit Drawers
the type declaration of IDrawer
has to be in the interface part of the unit. You have inserted it in the implementation part where it is only visible for in-unit declarations.
Here is the code:
unit Drawers;
interface
type
IDrawer = interface
['{070B4742-89C6-4A69-80E2-9441F170F876}']
procedure Draw();
end;
implementation
end.
Upvotes: 7
Reputation: 125728
Which uses clause do you add Drawers
to? It has to be in the interface
uses clause (above the definition of TField
that uses it).
Upvotes: 1