To help us modulate a monolithic application, we are in the process of creating packages for use in debug builds, while still compiling one instance for release.
One of our packages (EAUtils) contains a block that now produces [DCC Error] E2201 Need imported data reference ($G) to access 'SMsgDlgWarning' from unit 'SystemUtils'
.
This happens when creating the EAUtils package itself. I am not going to create packages that are still dependent on EAUtils. EAUtils depends only on rtl / vcl packages and the package I created for Jedi WinApi blocks.
This is the result of the lines:
// This is a TaskDialog override, with the same args as the old MessageDlg. function TaskDialog(const aContent: string; const Icon: HICON = 0; const Buttons: TTaskDialogCommonButtonFlags = TDCBF_OK_BUTTON): Integer; const Captions: array[TMsgDlgType] of Pointer = (@SMsgDlgWarning, @SMsgDlgError, @SMsgDlgInformation, @SMsgDlgConfirm, nil); var aMsgDlgType: TMsgDlgType; aTitle: string; begin aMsgDlgType := TaskDialogIconToMsgDlgType(Icon); if aMsgDlgType <> mtCustom then aTitle := LoadResString(Captions[aMsgDlgType]) else aTitle := Application.Title;
In particular, this is the result of the link SMsgDlgWarning
, SMsgDlgError
, SMsgDlgInformation
and SMsgDlgConfirm
, which are all declared in Vcl.Const
.
Please note that this code compiles without errors when we create one executable file.
As an optimization tool, our include file contains {$IMPORTEDDATA OFF}
, because it allows faster access to (global) variables and constants. See http://hallvards.blogspot.com/2006/09/hack13-access-globals-faster.html .
According to the error documentation ( http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/cm_package_varref_xml.html ) this is the reason and it says: "To alleviate the problem, it, as a rule, the easiest way is to turn on the $ IMPORTEDDATA switch and recompile the device that generates the error.
So, I installed {$IMPORTEDDATA ON}
in our include file and made it doubly sure by setting Use imported data references
to true in the Delphi Compiler | Compiling | Debugging
Delphi Compiler | Compiling | Debugging
Delphi Compiler | Compiling | Debugging
project parameters.
Unfortunately, contrary to the documentation, this did not alleviate the problem. Even setting this compiler directive directly above the violating code and redoing the package failed to fix the errors.
What else do I need to do to resolve this error E2201? Not sure, but it may be important that SMsgDlgWarning and his friends are resource strings?