Recent

Author Topic: Anonymous functions compiler switch error  (Read 2018 times)

AlexanderK

  • New Member
  • *
  • Posts: 17
Anonymous functions compiler switch error
« on: August 24, 2025, 05:18:56 pm »
I'm learning about anonymous functions and even before I write anything I get Warning: Illegal compiler switch "FUNCTIONREFERENCES+" and Warning: Illegal compiler switch "ANONYMOUSFUNCTIONS+". Why am I having a problem with the switches? (Using Lazarus 4.2). See the attached screenshot.

Code: Pascal  [Select][+][-]
  1. program anonymous_function1;
  2.  
  3. {$mode objfpc}{$H+}
  4. {$modeswitch functionreferences}
  5. {$modeswitch anonymousfunctions}
  6.  
  7. uses
  8.   {$IFDEF UNIX}
  9.   cthreads,
  10.   {$ENDIF}
  11.   { you can add units after this }
  12.   SysUtils;
  13.  
  14. begin
  15.   {$IfDef WINDOWS}
  16.   ReadLn;
  17.   {$EndIf}
  18. end.
  19.  
« Last Edit: August 24, 2025, 05:22:43 pm by AlexanderK »

jamie

  • Hero Member
  • *****
  • Posts: 7661
Re: Anonymous functions compiler switch error
« Reply #1 on: August 24, 2025, 05:27:49 pm »
Cause you need the Trunk compiler.

Welcome to the stone age!  :D

Jamie
The only true wisdom is knowing you know nothing

AlexanderK

  • New Member
  • *
  • Posts: 17
Re: Anonymous functions compiler switch error
« Reply #2 on: August 24, 2025, 05:56:55 pm »
Noted. Are these two {$modeswitch functionreferences} and {$modeswitch functionreferences} planned to be supported in the next stable version of FPC?

jamie

  • Hero Member
  • *****
  • Posts: 7661
Re: Anonymous functions compiler switch error
« Reply #3 on: August 24, 2025, 06:03:54 pm »
I can't answer that question.

 I am sure someone else may.

I am just a backyard bill hilly pounding at the keys.

Jamie
The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 18970
  • Glad to be alive.
Re: Anonymous functions compiler switch error
« Reply #4 on: August 24, 2025, 06:05:36 pm »
No. In the next major release, not in 3.2.4. which is just a bug fix release -but likely a future version named 3.4.0 or even 4.0.0. (fpc, not Lazarus).
This has been explained many times on this forum by the core developers.
To prevent such issues I often add:
Code: Pascal  [Select][+][-]
  1. {$if fpc_fullversion < 30301}{$error this code needs fpc 3.3.1. or higher}{$ifend}
But I did not always do that and most others do not do that too.
The above helps to mitigate the confusion, though.
If you want to use the new features (many) use trunk/main, built with fpcupdeluxe or by hand.
Beginners without manual compilation experience should use fpcupdeluxe.
You should not use trunk for production, but if you are a hobby programmer - of any level - there is almost no risk to use it, except of course that features may change and may contain bugs... You need to compile trunk on a regular basis, say, once a week, because it is a moving target and bug-fixes and new features are added all the time.
For example, trunk from a month ago did not have multiline string support, but trunk from a week later does have that support.
« Last Edit: August 24, 2025, 06:22:33 pm by Thaddy »
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

AlexanderK

  • New Member
  • *
  • Posts: 17
Re: Anonymous functions compiler switch error
« Reply #5 on: August 24, 2025, 06:29:01 pm »
Thanks, Thaddy!

 

TinyPortal © 2005-2018