Skip to content

Restore Delphi 7 compatibility#308

Open
TetzkatLipHoka wants to merge 1 commit into
remobjects:masterfrom
TetzkatLipHoka:fix/delphi7-compatibility
Open

Restore Delphi 7 compatibility#308
TetzkatLipHoka wants to merge 1 commit into
remobjects:masterfrom
TetzkatLipHoka:fix/delphi7-compatibility

Conversation

@TetzkatLipHoka

Copy link
Copy Markdown

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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need Old Delphi 7 for Legacy App

1 participant