Packages for C++ New Toolchain
Go Up to C++ Reference
Packages are fundamentally a Delphi concept and do not map perfectly to C++. This imperfect mapping causes issues and complexities when using packages.
For example, Delphi has the concept of units: a .pas file. C++ has translation units, but they are not the same thing. Code can exist in a header and not belong to any specific .cpp file.
To apply this, you must use #pragma package(smart_init) in a unit. Effectively, this marks a compilation unit as a Delphi-style unit (as close as the concepts can be mapped) in the sense ‘unit’ is used in this document and related articles.
Please review the following sections for a better understanding of this topic.
Contents
Unit initialization and finalization
In the new toolchain, RAD Studio has put considerable effort into improving how packages work and ensuring consistency in behavior when statically and dynamically linking packages.
For more information about this please review the Unit Initialization and Finalization for C++ New Toolchain article.
Package import and export
It can be hard to understand the effect of the PACKAGE or __declspec(package) modifier: please see the Package import and export article where you can find more information on this topic.
Weakly packaged units
In addition, you should be aware of how weakly packaged units differ from normal units.