Delphi Compiler Error
X1033 Unit ‘%s’ implicitly imported into package ‘%s’
Reason for the Error & Solution
This warning indicates that a unit has been implicitly linked into the package currently being compiled. Normally, units are involved in a package in one of two ways:
- Explicitly imported via the “Contains” folder
- Part of another package specified in the “Requires” folder
If a unit needed for compilation is not found in either the “Contains” folder or within a package specified in the “Requires” folder, the unit is implicitly imported as if it were included in the “Contains” folder.
This warning signals the programmer to consider explicitly adding the unit to the package or adding a reference to a package containing the missing unit.
To prevent this problem in the future, you need to add the .dcp file (which contains the compile and link information for the package) to either the Requires or Contains clause/folder:
- The Requires folder typically refers to other packages that contain units needed to compile this package. These packages can be from Delphi, such as the RTL package containing the System unit, SysUtils unit, and so on, or other packages created by the programmer containing user-defined units.
- The Contains folder involves the units to be included into the package, not counting units found in other packages listed in the “Requires” folder.
Fixing the Problem
In the Code Editor, you can add units to the “Requires” and “Contains” clauses by editing your code as necessary. In the Project Manager, you can add units to the “Requires” and “Contains” folders as described here.
To add a reference to the “Requires” folder in the Project Manager
- Right-click the “Requires” folder.
- Select Add Reference from the context menu.
- On the Add dialog, select the appropriate .dcp file or just type the referencing project .dcp file name if the file is in the search path.
- Then the .dcp will be listed in the “Requires” folder for the project.
To add a unit to the “Contains” folder in the Project Manager
- Right-click the “Contains” folder.
- Select either:
- Add New > Unit from the context menu to add an empty unit in the Contains folder (the Code Editor displays the template for the unit code.)
- Add from the context menu to display the Open dialog. Select the .pas file for the unit you want to add.
For example, in the following program,
Classes uses (either directly or indirectly)
You get a warning message for each of those used units.
The following program explicitly names all those units that will be imported into the package in the
contains clause to fix this issue:
contains consts, TypInfo, SysUtils, Classes;