Package-specific Compiler Directives

From RAD Studio
Jump to: navigation, search

Go Up to Compiling Packages

The following table lists package-specific compiler directives that you can insert into your source code.

Package-specific compiler directives:

C++ Directive Purpose
#pragma package(smart_init)

Ensures that packaged units are initialized in the order determined by their dependencies. (Included by default in package source file.)

#pragma package(smart_init, weak)

Packages a unit "weakly." See (Put this directive in unit source file.)

Delphi Directive Purpose

Prevents a package from being implicitly recompiled later. Use this directive in .dpk files when compiling packages that provide low-level functionality, that change infrequently between builds, or whose source code will not be distributed.


Disables creation of imported data references. This directive increases memory-access efficiency, but prevents the unit where it occurs from referencing variables in other packages.


Packages the unit "weakly". See Using the Weak Packaging Directive for details.


Prevents unit from being placed in a package.


Compiles the package for installation in the IDE. (Put in .dpk file.)


Compiles the package as run time only. (Put in .dpk file.)


  • Including {$DENYPACKAGEUNIT ON} in your source code prevents the unit file from being packaged.
  • Including {$G-} or {$IMPORTEDDATA OFF} may prevent a package from being used in the same application with other packages.
  • Packages compiled with the {$DESIGNONLY ON} directive should not ordinarily be used in applications, since they contain extra code required by the IDE.
  • Other compiler directives may be included, if appropriate, in package source code. See Compiler Directives for information on compiler directives not discussed here.

Refer to Creating Packages and DLLs for additional directives that can be used in all libraries.

See Also