W1033 Unit '%s' implicitly imported into package '%s' (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

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


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 Object Pascal, 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

  1. Right-click the "Requires" folder.
  2. Select Add Reference from the context menu.
  3. 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.
  4. 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

  1. Right-click the "Contains" folder.
  2. 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.


See Also