Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Created April 21, 2019 11:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpluimers/97711a50864d8b3ca9442d9b60d15391 to your computer and use it in GitHub Desktop.
Save jpluimers/97711a50864d8b3ca9442d9b60d15391 to your computer and use it in GitHub Desktop.
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/8ae6cf29ffc601fde7c1182dead740adddb13fb8/Native/Delphi/Library/RTL/ReturnAddressUnit.pas
unit ReturnAddressUnit;
// maps CallerAdddr to ReturnAddress to CallerAddr when not available (XE2 and higher have ReturnAddress)
// this avoids "W1000 Symbol 'CallerAddr' is deprecated: 'Use ReturnAddress'"
// from https://github.com/fabriciocolombo/dunit-extension/blob/master/src/TestCaseExtension.pas
interface
{$IFDEF CONDITIONALEXPRESSIONS}
{$IF (NOT DEFINED(CLR)) AND (CompilerVersion >= 23.0) }
{$DEFINE HAS_BUILTIN_RETURNADDRESS} // Requires ReturnAddress intrinsic function(Delphi XE2)
{$ENDIF}
{$ENDIF}
{$IFNDEF HAS_BUILTIN_RETURNADDRESS}
type
TReturnAddressFunc = function : Pointer;
var
ReturnAddress: TReturnAddressFunc = CallerAddr;
{$ENDIF}
implementation
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment