Failure when compiling code in i386 lazarus / 64-FPC development ---------------------------------------------------------------------- Чебурашка · 2024-03-04 08:35 It compiles in x86_64, but not in i386. What am I doing wrong? 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 program project1; var  i: Int64;  x1, x2: Int64;begin  x1 := 1;    x2 := 3; for i := x1 to x2 - 1 do  begin    Write('.');  end;  Writeln('');end.  This is compilation in a debian 11.5 x86_64: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i [09:27:35] mep@mep-development:~/tmp/2024-03-04-compile-32$ lazbuild -B project1.lpi; ./project1 Info: (lazarus) Execute Title="Compile Project, Target: project1"Info: (lazarus) Working Directory="/home/mep/tmp/2024-03-04-compile-32/"Info: (lazarus) Executable="/usr/bin/fpc"Info: (lazarus) Param[0]="-B"Info: (lazarus) Param[1]="-MObjFPC"Info: (lazarus) Param[2]="-Scghi"Info: (lazarus) Param[3]="-Cg"Info: (lazarus) Param[4]="-O1"Info: (lazarus) Param[5]="-g"Info: (lazarus) Param[6]="-gl"Info: (lazarus) Param[7]="-l"Info: (lazarus) Param[8]="-vewnhibq"Info: (lazarus) Param [9]="-Fi/home/mep/tmp/2024-03-04-compile-32/lib/x86_64-linux"Info: (lazarus) Param[10]="-Fu/home/mep/tmp/2024-03-04-compile-32/"Info: (lazarus) Param[11]="-FU/home/mep/tmp/2024-03-04-compile- 32/lib/x86_64-linux/"Info: (lazarus) Param[12]="-FE/home/mep/tmp/2024-03-04-compile-32/"Info: (lazarus) Param[13]="-o/home/mep/tmp/2024-03-04-compile-32/project1"Info: (lazarus) Param[14]="project1.lpr"Hint: (11030) Start of reading config file /etc/fpc.cfgHint: (11031) End of reading config file /etc/fpc.cfgFree Pascal Compiler version 3.2.0+dfsg-12 [2021/01/25] for x86_64Copyright (c) 1993-2020 by Florian Klaempfl and others(1002) Target OS: Linux for x86-64(3104) Compiling project1.lpr(9015) Linking /home/mep/tmp/2024-03-04-compile-32/project1(1008) 15 lines compiled, 0.1 sec(1022) 2 hint(s) issued  This is compilation in a debian 11.5 i386: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i mep@MEPCompilation-debian11-i386:~/2024-03-04-compile-32$ lazbuild -B project1.lpiHint: (lazarus) [RunTool] "/usr/bin/fpc" "-iWTOTP"Hint: (lazarus) [RunTool] "/usr/bin/fpc" "-va" "compilertest.pas"TProject.DoLoadStateFile Statefile not found: /home/mep/2024-03-04-compile-32/lib/i386-linux/project1.compiledHint: (lazarus) [RunTool] "/usr/bin/fpc" "-iWTOTP" "-Pi386" "-Tlinux"Hint: (lazarus) [RunTool] "/usr/bin/fpc" "-va" "compilertest.pas" "-Pi386" "-Tlinux"Info: (lazarus) Execute Title="Compile Project, Target: project1"Info: (lazarus) Working Directory="/home/mep/2024-03-04-compile-32/"Info: (lazarus) Executable="/usr/bin/fpc"Info: (lazarus) Param[0]="-B"Info: (lazarus) Param[1]="-MObjFPC"Info: (lazarus) Param[2]="-Scghi"Info: (lazarus) Param[3]="-O1"Info: (lazarus) Param[4]="-g"Info: (lazarus) Param[5]="-gl"Info: (lazarus) Param[6]="-l"Info: (lazarus) Param[7]="-vewnhibq"Info: (lazarus) Param[8]="-Fi/home/mep/2024-03-04-compile-32/lib/i386-linux"Info: (lazarus) Param[9]="-Fu/home/mep/2024-03-04-compile-32/"Info: (lazarus) Param[10]="-FU/home/mep/2024-03-04-compile-32/lib/i386-linux/"Info: (lazarus) Param[11]="-FE/home/mep/2024-03-04-compile-32/"Info: (lazarus) Param[12]="-o/home/mep/2024-03-04-compile-32/project1"Info: (lazarus) Param[13]="project1.lpr"Hint: (11030) Start of reading config file /etc/fpc.cfgHint: (11031) End of reading config file /etc/fpc.cfgFree Pascal Compiler version 3.2.0+dfsg-12 [2021/01/25] for i386Copyright (c) 1993-2020 by Florian Klaempfl and others(1002) Target OS: Linux for i386(3104) Compiling project1.lpr/home/mep/2024-03-04-compile-32/project1.lpr(9,7) Error: (4007) Ordinal expression expectedproject1.lpr(16) Fatal: (10026) There were 1 errors compiling module, stoppingFatal: (1018) Compilation abortedError: /usr/bin/ppc386 returned an error exitcodeError: (lazarus) Compile Project, Target: project1: stopped with exit code 1Error: (lazbuild) failed compiling of project /home/mep/2024-03-04-compile-32/project1.lpi ---------------------------------------------------------------------- Zvoni · 2024-03-04 08:40 Quote from: Чебурашка on March 04, 2024, 09:35:17 amIt compiles in x86_64, but not in i386. What am I doing wrong? Not reading the Documentation https://www.freepascal.org/docs-html/ref/refsu4.html QuoteRemark Int64 and QWord are considered ordinal types on 64-bit CPUs. On 32-bit types they have some of the characteristics of ordinals, but they cannot be used e. g. in for loops. ---------------------------------------------------------------------- cdbc · 2024-03-04 09:16 Hi Try and use "PtrInt" instead of int64. Ptrint is an alias for the integer of pointer-size on the platform, i.e.: on 64 bit it'll be an int64 and on 32 bit it'll be a longint. I even think it'll be a smallint on 16 bit... The same logic goes for "PtrUint" -> 64bit = QWord, 32bit = Cardinal & 16bit = Word. Regards Benny ---------------------------------------------------------------------- rvk · 2024-03-04 09:18 Unless you really need a int64 for a very very big loop (otherwise you shouldn't have used it in 64 bit anyway). In case of a very very big loop you'll need to reconstruct this into a while loop. ---------------------------------------------------------------------- Чебурашка · 2024-03-04 09:28 Quote from: rvk on March 04, 2024, 10:18:56 amUnless you really need a int64 for a very very big loop (otherwise you shouldn't have used it in 64 bit anyway). The Int64 comes from a db whose field is a LargeInt, but that isn't visible in the posted example. Quote from: rvk on March 04, 2024, 10:18:56 amIn case of a very very big loop you'll need to reconstruct this into a while loop. Thank you, is what I already did once I got into this compile error. ---------------------------------------------------------------------- Zvoni · 2024-03-04 09:40 Quote from: rvk on March 04, 2024, 10:18:56 amIn case of a very very big loop you'll need to reconstruct this into a while loop. Shouldn't that be a Repeat-Loop? A For-Loop runs through it at least once, provided correct bounderies are provided (which should cause a compile-error if not --> e.g. For i:=2 To 0 Do --> should not compile, but it does), so we're back at the While-Loop Depending on your Use-case (where are the Low/High of the loop coming from?) you have to implement a logic-check ("high">="Low" And Not MyExitCriteria) EDIT: The "High">="Low"-Check should be just before the Loop, to check only once ---------------------------------------------------------------------- rvk · 2024-03-04 09:47 Quote from: Zvoni on March 04, 2024, 10:40:05 amQuote from: rvk on March 04, 2024, 10:18:56 amIn case of a very very big loop you'll need to reconstruct this into a while loop. Shouldn't that be a Repeat-Loop? A For-Loop runs through it at least once, provided correct bounderies are provided (which should cause a compile-error if not --> e.g. For i:=2 To 0 Do --> should not compile, but it does), so we're back at the While-Loop Depending on your Use-case (where are the Low/High of the loop coming from?) you have to implement a logic-check ("high">"Low" And MyExitCriteria) Yep. That's why it should be a while loop and not a repeat-loop. A for loop isn't guaranteed to do the loop at least once. Any for loop can be substituted for a while. Not every for loop can be subsisted for a repeat loop, just because of that first loop (unless you do an if check in front of it)