E2065
Delphi Programming Language
Severity: MinorWhat Does This Error Mean?
E2065 means you declared a function or procedure with the 'forward' keyword but never wrote the actual implementation. A forward declaration tells Delphi 'this function exists and will be defined later' — but then you must actually define it. If you forward-declare a routine and never provide the implementation, Delphi raises E2065 at the end of the unit. The fix is to write the full implementation of the forward-declared routine.
Affected Models
- Delphi 2
- Delphi 7
- Delphi XE
- Delphi 10.x
- Delphi 11
- Delphi 12
- All modern Delphi versions
Common Causes
- Declaring a function or procedure with 'forward' in the interface or at the top of the implementation section, and never writing the body
- Writing the implementation but with a slightly different signature than the forward declaration (causing Delphi not to match them)
- Deleting the implementation of a forward-declared function without removing the forward declaration
- Declaring an external function (with the 'external' directive) using a DLL function name that does not exist in the DLL
- Renaming a function but forgetting to update both the forward declaration and the implementation
How to Fix It
-
Search for 'forward' in your unit to find all forward declarations. Each one must have a matching implementation somewhere below it in the same unit.
In the Delphi IDE, use Ctrl+F to search for 'forward' within the file.
-
Write the full implementation for the forward-declared routine in the implementation section. The signature must match exactly — same function name, same parameters, same return type.
The implementation does not use the 'forward' keyword — just the normal procedure/function header followed by begin..end.
-
If the forward-declared routine is no longer needed, remove the forward declaration entirely.
Unused forward declarations are dead code. Remove them to keep the codebase clean.
-
If the error is about an 'external' declaration (a DLL function), verify the function name is spelled exactly as it appears in the DLL, including case sensitivity.
Use a tool like Dependency Walker or dumpbin to inspect the exported function names in the DLL.
-
Compare the forward declaration and the implementation side by side. Even a small difference — an extra parameter, a different type, or different capitalization in Delphi's strict mode — can prevent Delphi from matching them.
Delphi matches forward declarations by signature. If the implementation signature differs even slightly, Delphi treats them as different routines.
When to Call a Professional
E2065 is always a compile-time error you can fix yourself. Search for the forward declaration and either write the implementation or remove the forward declaration if it is no longer needed.
Frequently Asked Questions
What is a forward declaration in Delphi?
A forward declaration tells the compiler that a function exists before showing it the full implementation. This allows two functions to call each other (mutual recursion) — A calls B and B calls A — which would otherwise be impossible since the compiler reads top to bottom. Example: procedure B; forward; (tells compiler B exists) procedure A; begin B; end; (can now call B even though B is not fully defined yet) procedure B; begin A; end; (the actual implementation of B)
Is there a way to avoid forward declarations?
Often yes — reordering your procedures and functions so they appear before the routines that call them removes the need for forward declarations. Forward declarations are mainly needed for mutual recursion (where two routines call each other) or when the structure of the code requires a specific order. In object classes, forward declarations are handled differently — method signatures go in the class declaration and implementations go in the implementation section.
What is the 'external' directive in Delphi?
The 'external' directive declares a function that is implemented in an external DLL (dynamic link library), not in your Delphi code. Example: function MessageBox(hWnd: HWND; lpText, lpCaption: PChar; uType: UINT): Integer; external 'user32.dll'; Delphi will link to the DLL at runtime. If the DLL or the function name is wrong, you get E2065 at compile time or a runtime error when loading.