Recent

Author Topic: {$mode delphi} and dynamic array initializers, is there a modeswitch?  (Read 798 times)

prof7bit

  • Full Member
  • ***
  • Posts: 161
This works in delphi mode:

Code: Pascal  [Select][+][-]
  1. program Project1;
  2. {$mode delphi}
  3.  
  4. type
  5.   TArr = array of Integer;
  6.  
  7. const
  8.   // objfpc would not allow me to use these kind of
  9.   // initializers or any kind of dyn array initializers
  10.   // that I am aware of at all. Delphi mode does!
  11.   Foo: TArr = [1,2,3];
  12.   Bar: TArr = [1,2,3,4,5];
  13.  
  14. begin
  15. end.
  16.  

Do I really need to set the unit to Delphi mode for this to work or is there also a {$modeswitch xyz} where I can just turn on this one feature?

prof7bit

  • Full Member
  • ***
  • Posts: 161
Re: {$mode delphi} and dynamic array initializers, is there a modeswitch?
« Reply #1 on: September 06, 2021, 03:26:01 pm »
I'm now going to answer my own post:

Instead of [] just use () and it works. I think I should read the release notes of new FPC versions more carefully, until 5 minutes ago I was 100% convinced it would not be possible in FPC.
« Last Edit: September 06, 2021, 03:27:54 pm by prof7bit »

 

TinyPortal © 2005-2018