Jump to content
IndexCon

Delphi Mac OSX 64bits exceptions with try except not working

Recommended Posts

I am developing an application for MAC OSX 64 bits, using Delphi 10.3 and macOS Big Sur, I run into a problem trying to catch exceptions and I cannot find the solution. When an exception occurs the execution cycle does not go into the Try / Except, it seems that RTL gives an error when performing the Raise of the Exception and triggers a new 'Access Violation' exception that goes into a loop. Below you can find the test code that produces the error:

 

 

 
Unit8;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.Controls.Presentation, FMX.StdCtrls;

type
  TForm8 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  function Str2Float(str : String) : Extended;

var
  Form8: TForm8;

implementation

{$R *.fmx}

procedure TForm8.Button1Click(Sender: TObject);
var
  f : extended;
begin
  f:=str2float('10,7');
  ShowMessage ('Resultat : '+floattostr(f));
end;

function Str2Float(str : String) : Extended;
var
  dec : Char;
begin
  result := 0;
  if length(str) > 0 then begin
    dec := FormatSettings.DecimalSeparator;
    FormatSettings.DecimalSeparator := '.';
    try
      result := strtofloat(str);
    except
      on e : Exception do begin
        FormatSettings.DecimalSeparator := ',';
        try
          result := strtofloat(str);
        except
          on e : Exception do begin
            result := 0;
          end;
        end;
      end;
    end;
    FormatSettings.DecimalSeparator := dec;
  end;
end;

end.

 

Thank you very much for the help

 

 

 

Share this post


Link to post

Then is a problem only with new version of MAC OS? do you said that if I execute the code with MAC OS Catalina the problem not exist?

 

Thanks.

Share this post


Link to post

RonaldK thank you very much for your advice, I have updated to Delphi 10.4.2 and the problem has been resolved.
What I don't understand is that, every time a new version of MacOS appears we will have to recompile our application, this does not happen with Windows, I have an application compiled in 2001 that continues to work perfectly today, without the need to recompile. It forces us to buy MAC machines every so often and to pay for compiler updates.
Again, thank you very much for your advice.

Share this post


Link to post
16 minutes ago, IndexCon said:

What I don't understand is that, every time a new version of MacOS appears we will have to recompile our application, this does not happen with Windows, I have an application compiled in 2001 that continues to work perfectly today, without the need to recompile. It forces us to buy MAC machines every so often and to pay for compiler updates.

Apple does not value backward compatibility as much as Microsoft. They make breaking changes a lot, either in OS or their toolchain and that causes various issues. Some issues break application building process, some break applications. 

 

  • Like 1

Share this post


Link to post
On 2/25/2021 at 6:23 PM, IndexCon said:

What I don't understand is that, every time a new version of MacOS appears we will have to recompile our application, ..

Easy to understand: Apple want to punish their loyal developers with maximal pain as reward 🙂

If you want to be in their exclusive club, you have to enter using their back entry veeeery deeply.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×