Delphi Error – F2047 Circular unit reference to ‘%s’

Delphi Compiler Error

F2047 Circular unit reference to ‘%s’

Reason for the Error & Solution

One or more units use each other in their interface parts.

As the compiler has to translate the interface part of a unit before any other unit can use it, the compiler must be able to find a compilation order for the interface parts of the units.

Check whether all the units in the uses clauses are really necessary, and whether some can be moved to the implementation part of a unit instead.

unit A;
interface
uses B;           (*A uses B, and B uses A*)
implementation
end.

unit B;
interface
uses A;
implementation
end.

The problem is caused because A and B use each other in their interface sections.

unit A;
interface
uses B;          (*Compilation order: B.interface, A, B.implementation*)
implementation
end.

unit B;
interface
implementation
uses A;          (*Moved to the implementation part*)
end.

Note: This can be fixed in one of two ways:

  • You can put the mutually referring classes inside the same unit and use forward declarations to resolve the problems.
  • Change the conflicting type to a more general type such as TObject or Pointer and use type casts to the previous type that caused the conflict (this can only be done in the case where the type is used internally.)

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...