Ad Space — Top Banner

E2003

Delphi Programming Language

Severity: Minor

What Does This Error Mean?

Error E2003 means you used a name (a variable, function, type, or unit) that Delphi has not seen declared anywhere. Delphi must know about every identifier before you can use it. This is the Delphi equivalent of Python's NameError — the name simply does not exist as far as the compiler is concerned.

Affected Models

  • Delphi 2005 and later
  • RAD Studio
  • Lazarus/Free Pascal (similar error)

Common Causes

  • A typo in the identifier name — Delphi is not case-sensitive, but spelling must be exact
  • Using a variable or function that was declared in a different unit without adding that unit to the uses clause
  • Using an identifier before it is declared — Delphi reads the file top to bottom and a forward declaration may be needed
  • A variable or function declared in the implementation section being accessed from the interface section
  • Using a type, constant, or variable that belongs to a library that has not been installed or referenced

How to Fix It

  1. Read the error message — it tells you the exact identifier Delphi cannot find. Search your code for its declaration (the place where it is defined with var, const, type, function, or procedure).

    In the Delphi IDE, double-click the error in the Messages window to jump to the line with the problem.

  2. Check for a typo. Even though Delphi is not case-sensitive, the spelling must be exactly right. Compare the name in the error to all declarations.

    Use Ctrl+F to search the whole unit for the identifier name.

  3. If the identifier is defined in another unit, add that unit to the uses clause at the top of your file (either in the interface uses or implementation uses section).

    Example: if you use TStringList without adding Classes to your uses, you get E2003.

  4. If you are calling a function defined later in the same file, add a forward declaration. Write the function signature followed by the word 'forward' before the first call to it.

    Example: procedure MyProc; forward; — then define it fully later in the file.

  5. If the identifier is a type or component from a third-party library, make sure the library is installed in Delphi and its unit is in the uses clause.

    Check Tools → Component Library or the library's installation instructions.

When to Call a Professional

E2003 is always something you can fix yourself. The error message includes the identifier name that was not found. Check spelling, check the uses clause, and check where the identifier is declared.

Frequently Asked Questions

Why does Delphi not automatically find identifiers from other units?

Delphi compiles each unit independently. To use something from another unit, you must explicitly list that unit in your uses clause. This keeps compilation fast and makes dependencies clear — you always know exactly which units a piece of code depends on.

What is a forward declaration and when do I need one?

A forward declaration tells Delphi 'this function exists, I will define it later'. You need it when function A calls function B, but function B is defined after function A in the same file. Without a forward declaration, Delphi reaches function A, sees the call to B, and raises E2003 because it has not seen B yet.

I added the unit to the uses clause but still get E2003 — why?

Make sure the unit is in the correct section of the uses clause. Some identifiers are only available if the unit is in the interface uses (not just the implementation uses). Also check you have the right unit name — for example, the correct unit for many VCL controls is Vcl.Controls, not just Controls.