Restore Delphi 7 compatibility#308
Open
TetzkatLipHoka wants to merge 1 commit into
Open
Conversation
Recent changes made the core units unbuildable on old Delphi versions (reported for Delphi 7 in issue remobjects#286). Three categories of fixes, all behavior-neutral on current compilers: - Exit(Value) needs Delphi 2009+: expanded to 'Result := ...; Exit;' in the for-loop code generation (EmitForEntryCheck/EmitForExitCheck). - High(UInt64)/High(tbtU64) is not evaluable as a constant expression on Delphi 7 (its UInt64 is a crippled signed alias): replaced with 'not UInt64(0)', which yields the same all-ones value everywhere. - 'tbtDouble(p^.textended)' is an invalid typecast on Delphi 7 (Extended -> Double must be a conversion): assign without the cast, which is the intended float conversion on every compiler. - SysUtils.StrToUInt64/StrToUInt64Def (XE4+) and SysUtils.UIntToStr (2009+) do not exist on old RTLs: uPSUtils now provides fallbacks, compiled only when SysUtils lacks them (checked via {$IF NOT DECLARED(...)}, so this adapts to any compiler and to FPC). The two qualified SysUtils.UIntToStr calls in uPSRuntime were unqualified so they resolve to whichever implementation exists. Note: pre-2010 compilers format UInt64 values above High(Int64) with a sign - an inherent limitation of their signed UInt64 alias. With this, all uPS* units (including the import units) compile on Delphi 7 again; Delphi 12 Win32/Win64 builds are unchanged. Fixes remobjects#286 (the current sources can be used on Delphi 7 again). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recent changes made the core units unbuildable on old Delphi versions
(reported for Delphi 7 in issue #286). Three categories of fixes, all
behavior-neutral on current compilers:
Exit(Value) needs Delphi 2009+: expanded to 'Result := ...; Exit;' in
the for-loop code generation (EmitForEntryCheck/EmitForExitCheck).
High(UInt64)/High(tbtU64) is not evaluable as a constant expression on
Delphi 7 (its UInt64 is a crippled signed alias): replaced with
'not UInt64(0)', which yields the same all-ones value everywhere.
'tbtDouble(p^.textended)' is an invalid typecast on Delphi 7
(Extended -> Double must be a conversion): assign without the cast,
which is the intended float conversion on every compiler.
SysUtils.StrToUInt64/StrToUInt64Def (XE4+) and SysUtils.UIntToStr
(2009+) do not exist on old RTLs: uPSUtils now provides fallbacks,
compiled only when SysUtils lacks them (checked via
{$IF NOT DECLARED(...)}, so this adapts to any compiler and to FPC).
The two qualified SysUtils.UIntToStr calls in uPSRuntime were
unqualified so they resolve to whichever implementation exists.
Note: pre-2010 compilers format UInt64 values above High(Int64) with
a sign - an inherent limitation of their signed UInt64 alias.
With this, all uPS* units (including the import units) compile on
Delphi 7 again; Delphi 12 Win32/Win64 builds are unchanged.
Fixes #286 (the current sources can be used on Delphi 7 again).
Fixes #286.
🤖 Generated with Claude Code