Recent

Author Topic: Line compiles in CodeTyphon but not in Lazarus  (Read 2170 times)

fxeconomist

  • New Member
  • *
  • Posts: 36
Line compiles in CodeTyphon but not in Lazarus
« on: April 07, 2024, 09:04:33 pm »
I just ported my project to Lazarus and it failed to compile something interesting.

Code: Pascal  [Select][+][-]
  1. type TCoords3dNum=array [0..2] of extended;  
  2.      
  3.      TTriangle3dNum=record
  4.                       Points:array[0..2] of TCoords3dNum;
  5.                       GroupID,PieceID:longint; //added for convenience
  6.                     end;      
  7.  
  8.      TMesh=array of TTriangle3dNum;  
  9.  
  10. var meshCube: TMesh;
  11.  
  12. procedure InitMeshes;//for testing purposes
  13. var i,j:integer;
  14. begin
  15.   SetLength(meshCube, 12);
  16.   //SOUTH
  17.   meshCube[0].points:=[ [0,0,0], [0,1,0], [1,1,0] ];  meshCube[0].GroupID:=0;

The array assignment fails with:
Error: incompatible Types: Got "{Array of Const/Constant Open} Array of {Array of Const/Constant Open} Array of Shortint" expected "TTriangle3dNum.Array[0..2] of TCoords3dNum"

If I add a .0 to numbers then it says Array of Single.

So, what's the catch ? Is there a compiler setting to allow this kind of syntax ?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5508
  • Compiler Developer
Re: Line compiles in CodeTyphon but not in Lazarus
« Reply #1 on: April 07, 2024, 09:28:38 pm »
So, what's the catch ? Is there a compiler setting to allow this kind of syntax ?

Assignment of array constructors to static arrays is only supported in FPC 3.3.1, but not in the 3.2 series.

fxeconomist

  • New Member
  • *
  • Posts: 36
Re: Line compiles in CodeTyphon but not in Lazarus
« Reply #2 on: April 08, 2024, 08:26:14 am »
Can I just change the FPC compiler inside Lazarus ?

I don't necessarily need that thing right now, but it's a really neat thing. I coded some OpenScad, and it's pushed to insane levels there.

Thaddy

  • Hero Member
  • *****
  • Posts: 14572
  • Sensorship about opinions does not belong here.
Re: Line compiles in CodeTyphon but not in Lazarus
« Reply #3 on: April 08, 2024, 08:36:42 am »
No, becauuse Lazarus itself needs to be compiled with that same compiler.
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

wp

  • Hero Member
  • *****
  • Posts: 11988
Re: Line compiles in CodeTyphon but not in Lazarus
« Reply #4 on: April 08, 2024, 10:00:03 am »
Can I just change the FPC compiler inside Lazarus ?
If you want to switch to FPC 3.3.1 you check out the current FPC sources from gitlab. Then you build the compiler based on FPC 3.2.2 - there are several posts here or in the wiki on this topic. In "Tools" > "Options" > "Environment" > "Files" under "Compiler executable" you can specify the newly created FPC to be used by Lazarus. Make sure that the entries under "FPC source directory" and "Make executable" point to the correct directories/files for the new FPC. It might also be helpful to run "Tools" > "Rescan FPC source directory" afterwards. Finally you rebuild the IDE with the new compiler under "Tools" > "Configure Build Lazarus": check "Clean All" and "Switch after building to automatically", click "Build"
« Last Edit: April 08, 2024, 10:01:56 am by wp »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5508
  • Compiler Developer
Re: Line compiles in CodeTyphon but not in Lazarus
« Reply #5 on: April 11, 2024, 10:42:23 pm »
No, becauuse Lazarus itself needs to be compiled with that same compiler.

No, that is not true. It is perfectly valid to use a different compiler than the one the IDE has been compiled with. If one changes the compiler the LCL and related packages will even be recompiled on the fly with the new compiler.

Thaddy

  • Hero Member
  • *****
  • Posts: 14572
  • Sensorship about opinions does not belong here.
Re: Line compiles in CodeTyphon but not in Lazarus
« Reply #6 on: April 12, 2024, 09:36:21 am »
That is in effect the same thing as I meant.
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

wp

  • Hero Member
  • *****
  • Posts: 11988
Re: Line compiles in CodeTyphon but not in Lazarus
« Reply #7 on: April 12, 2024, 11:21:11 am »
That is in effect the same thing as I meant.
But you wrote the opposite: To the question "Can I just change the FPC compiler inside Lazarus ?" you answered "No"

rvk

  • Hero Member
  • *****
  • Posts: 6190
Re: Line compiles in CodeTyphon but not in Lazarus
« Reply #8 on: April 12, 2024, 12:10:39 pm »
That is in effect the same thing as I meant.
But you wrote the opposite: To the question "Can I just change the FPC compiler inside Lazarus ?" you answered "No"
From the "because" it's clear that if you compile Lazarus with newer FPC the answer would be yes ;)
No, becauuse Lazarus itself needs to be compiled with that same compiler.

Could also be...
No Yes, becauuse but Lazarus itself needs to be compiled with that same compiler.

It should be noted that using a different FPC compiler, than the one intended for that Lazarus version, can give some unexpected results  :D

 

TinyPortal © 2005-2018