F2047 ユニット '%s' への循環参照です(Delphi)

提供: RAD Studio
移動先: 案内検索

エラーと警告のメッセージ(Delphi) への移動


1 つ以上のユニットが interface セクションで互いに使用されています。

ユニットはその interface セクションをコンパイラが変換してからでなければ他のどのユニットでも使用できないので、コンパイラは関係するユニットの interface セクションのコンパイル順序を決定できる必要があります。

uses 句に指定されているユニットがすべて本当に必要かどうか、およびユニットの implementation セクションに移動できるものがないかどうかを確認してください。


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

unit B;
interface
uses A;
implementation
end.


この問題が発生するのは、A と B が互いの interface セクション部で使用されているためです。


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.


メモ: これは次のいずれかの方法で修正できます。

  • 互いに参照し合うクラスを同じユニット内に格納し、前方宣言を使用する。
  • 競合する型を TObject や Pointer などのより一般的な型に変更し、競合の原因となった前の型への型キャストを使用する(これを行えるのは型が内部的に使用されている場合だけです)。