Created
April 21, 2019 11:10
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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