[Function References ] not work on MACOS FPC 3.3.1 lazarus / 64-FPC development ---------------------------------------------------------------------- cai · 2023-04-01 03:23 {$modeswitch functionreferences} ============================= type   TProc =reference to procedure; ======================== Compile & print out Error: Identifier not found "reference " ---------------------------------------------------------------------- cai · 2023-04-01 04:37 OK,I was wrong! it is cause by {$mode objfpc} =================== failed code --------- Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$modeswitch functionreferences}{$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs; type   { TForm1 }   TForm1 = class(TForm)    procedure FormCreate(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.frm} type  TProc =reference to procedure; { TForm1 } procedure TForm1.FormCreate(Sender: TObject);var  P: TProc;begin end; end.  ============== succeed code --------------- Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$modeswitch functionreferences}//{$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs; type   { TForm1 }   TForm1 = class(TForm)    procedure FormCreate(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.frm} type  TProc =reference to procedure; { TForm1 } procedure TForm1.FormCreate(Sender: TObject);var  P: TProc;begin end; end.   why? ---------------------------------------------------------------------- cai · 2023-04-01 04:44 I was wrong! again! {$mode objfpc} should be put in front of {$modeswitch} Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$mode objfpc}{$H+}{$modeswitch functionreferences} ---------------------------------------------------------------------- Thaddy · 2023-04-01 07:43 The reason being that {$mode} is actually a set of {$modeswitches}. It is documented that for the time being {$modeswitch functionreferences} does not belong to any mode yet. This may change in the future, though. https://wiki.freepascal.org/FPC_New_Features_Trunk#Support_for_Functio n_References_and_Anonymous_Functions https://forum.lazarus.freepascal.org/index.php/topic,59468.0.html It is likely the modeswitch  will part of {$mode delphi} and {$mode objfpc} in the future. https://forum.lazarus.freepascal.org/index.php/topic,59468.msg443373.h tml#msg443373 ( but that' s why it is in trunk only: it needs testing and it needs to mature ) ---------------------------------------------------------------------- PascalDragon · 2023-04-01 14:23 Quote from: cai on April 01, 2023, 06:44:18 amI was wrong! again! {$mode objfpc} should be put in front of {$modeswitch} Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$mode objfpc}{$H+}{$modeswitch functionreferences}  A {$mode ...} directive resets any {$modeswitch ...} directive.