Skip to content

Fix Delphi Linux StrToFloat build#299

Open
MaxLogic wants to merge 1 commit into
remobjects:masterfrom
MaxLogic:fix/linux-strtofloat
Open

Fix Delphi Linux StrToFloat build#299
MaxLogic wants to merge 1 commit into
remobjects:masterfrom
MaxLogic:fix/linux-strtofloat

Conversation

@MaxLogic

Copy link
Copy Markdown

Summary

This fixes a Delphi Linux build failure in uPSUtils.StrToFloat.

On Delphi/Linux, the current implementation calls:

Val(string(s), Result, i);

where Result is Extended. That fails to compile because Delphi Linux does not support Extended as a distinct floating-point target in this context.

The patch keeps the existing Val implementation for Windows and FPC, and uses SysUtils.StrToFloat with invariant format settings only for Delphi/Linux. That preserves PascalScript's dot-decimal parsing behavior without changing the existing non-Linux path.

Verification

Verified in a downstream Delphi 12 project where the current upstream uPSUtils.pas failed during a Linux64 build with:

error E2008: Incompatible types
Val(string(s), Result, i);

After this change, the same downstream execute Linux64 Release build completes successfully.

@evgeny-k

Copy link
Copy Markdown
Contributor

you can use DELPHI_LINUX condition like

{$IFNDEF DELPHI_LINUX}
var
  i: longint;
{$ENDIF}
begin
  {$IFDEF DELPHI_LINUX}
  Result := SysUtils.StrToFloat(string(s), TFormatSettings.Invariant);
  {$ELSE}
  Val(string(s), Result, i);
  if i <> 0 then raise Exception.Create(RPS_InvalidFloat);
  {$ENDIF}
end;

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.

2 participants