From a check-in a while ago, when some Delphi versions complained about CallerAddr
having been replaced by ReturnAddress
and other versions not understanding ReturnAddress
, but having CallerAddr
.
The code in the [WayBack] gist and on [WayBack] BitBucket:
ReturnAddressUnit
to provide ReturnAddress
to Delphi versions not supporting it, and prevent CallerAddr
warnings for Delphi versions having ReturnAddress
. See https://bitbucket.org/jeroenp/wiert.me/src/…/Native/Delphi/Library/RTL/ReturnAddressUnit.pas
Basically the code maps a variable having a variable ReturnAddress
that is a function reference returning a pointer to a function and redirects to CallerAddr
when there is no ReturnAddress
available. This is the case for anything below Delphi XE2, and avoids W1000 Symbol 'CallerAddr' is deprecated: 'Use ReturnAddress'
for Delphi XE2 and up
It is an extract from [WayBack] dunit-extension/TestCaseExtension.pas at master · fabriciocolombo/dunit-extension · GitHub.
There is more interesting code in [WayBack] GitHub – fabriciocolombo/dunit-extension: Extended DUnit TestCase provides assertions to the types Date, Enumerator, Double, and other types, and a class to help run tests with output as XML, text and GUI mode and even more in [WayBack] fabriciocolombo (Fabricio Colombo) · GitHub , which are on my list of things to play with in the future.
Some more [WayBack] commits are at [WayBack] GitHub – cesarliws/dunit-extension (more on [WayBack] Cesar Romero tomorrow).
I think the code from Fabricio is inspired by [WayBack] ZeosLib/TestFrameWork.pas at master · svn2github/ZeosLib · GitHub as it uses the same HAS_BUILTIN_RETURNADDRESS
define.
The code by Fabricio is smarter though.
Via: “Delphi” “CallerAddr” “ReturnAddress” – Google Search
–jeroen
Read the rest of this entry »
Like this:
Like Loading...