Quantcast
Channel: Planet Object Pascal
Viewing all articles
Browse latest Browse all 1725

The Wiert Corner - irregular stream of stuff: jpluimers

$
0
0

I recently had an error like this when building with packages:

[DCC Error] E2201 Need imported data reference ($G) to access 'VarCopyProc' from unit 'SynCommons'

It was a bit hard to find good information about this error, mainly because of two reasons:

  1. the documentation on E2201 Need imported data reference ($G) to access ‘%s’ from unit ‘%s’ isn’t very well written
  2. [dcc error] e2201 need imported data reference ($g) to access ‘varcopyproc’ from unit – Google Search doesn’t yield very good answers

Finally, it was the FastMM and D2007 – Delphi Language BASM – BorlandTalk.com thread pointing me to Hallvard’s Blog: Hack#13: Access globals faster ($ImportedData).

That explained the error was caused by:

  • VarCopyProc being a variable in one package
  • VarCopyProc access being needed from the package that failed to compile
  • Not having {$G+} or {$IMPORTEDDATA ON} in the failing package would prevent that access

Somehow that does not work for all cases. Apparently, the VarCopyProc isn’t exported from the Delphi RTL as that package is compiled in the $G- state.

So I had to add the USEPACKAGES define to the conditional defines list, which forces the SynCommons to use the standard version of the RecordCopy method in stead of a highly optimized one that calls VarCopyProc.

–jeroen


Filed under: Delphi, Delphi XE2, Delphi XE3, Development, Software Development

Viewing all articles
Browse latest Browse all 1725

Trending Articles