E2065 Unsatisfied forward or external declaration '%s' (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Error and Warning Messages (Object Pascal) Index

This error message appears when you have a forward or external declaration of a procedure or function, or a declaration of a method in a class or object type, and you don't define the procedure, function or method anywhere.

Maybe the definition is really missing, or maybe its name is just misspelled.

Note that a declaration of a procedure or function in the interface section of a unit is equivalent to a forward declaration - you have to supply the implementation (the body of the procedure or function) in the implementation section.

Similarly, the declaration of a method in a class or object type is equivalent to a forward declaration.


program Produce;

type
  TMyClass = class
  constructor Create;
  end;

function Sum(const a: array of Double): Double; forward;

function Summ(const a: array of Double): Double;
var
  i: Integer;
begin
  Result := 0.0;
  for i:= 0 to High(a) do
  Result := Result + a[i];
end;

begin
end.

The definition of Sum in the above example has an easy-to-spot typo.


program Solve;

type
  TMyClass = class
  constructor Create;
  end;

constructor TMyClass.Create;
begin
end;

function Sum(const a: array of Double): Double; forward;

function Sum(const a: array of Double): Double;
var
  i: Integer;
begin
  Result := 0.0;
  for i:= 0 to High(a) do
  Result := Result + a[i];
end;

begin
end.

The solution: make sure the definitions of your procedures, functions and methods are all there, and spelled correctly.