Recent

Author Topic: UOS Not Compiling on trunk (possible fix)  (Read 3055 times)

Josh

  • Hero Member
  • *****
  • Posts: 1446
UOS Not Compiling on trunk (possible fix)
« on: January 01, 2025, 08:41:48 pm »
Hi

Downloaded latest trunk of laz&fpc
and my app stopped working.

If i explicitly cast to int64 it works again, does this break anything else?
in uos.pas around line 11076
Code: Pascal  [Select][+][-]
  1. if StreamIn[x].AACI.lwDataLen > (StreamIn[x].AACI.BitsPerSample div 8) then
  2.             StreamIn[x].Data.outframes := trunc (int64(StreamIn[x].AACI.lwDataLen) Div (int64(StreamIn[x].AACI.
  3.                                           BitsPerSample) Div 8))          
                               
« Last Edit: January 01, 2025, 08:45:56 pm by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: UOS Not Compiling on trunk (possible fix)
« Reply #1 on: January 02, 2025, 01:18:22 am »
Hello Josh.

Tested here with fpc 3.2.2 and 3.2.4 on Windows and Linux and SimplePlayer compiles ok.
So I suppose that you are using fpc 3.3.1.
What OS are you using?
What error message at compilation?
AACI.lwDataLen and AACI.BitsPerSample are declared as longword (so unsigned 32 bit).

Data.outframes is declared cint32 on 32 bit OS and cint64 on 64 bit OS.

Maybe there is something to adapt for last trunk fpc 3.3.1.

Quote
If i explicitly cast to int64 it works again, does this break anything else?
in uos.pas around line 11076

Hum, at first look I dont think it could be problems, maybe the code must be adapted for 64 bit or 32 bit OS.

Advises are welcome.

[EDIT] So, to resume, if I understood ok, this does not compiles on fpc trunk:
Code: Pascal  [Select][+][-]
  1. if StreamIn[x].AACI.lwDataLen > (StreamIn[x].AACI.BitsPerSample div 8) then
  2.             StreamIn[x].Data.outframes := trunc (StreamIn[x].AACI.lwDataLen Div (StreamIn[x].AACI.
  3.                                           BitsPerSample Div 8))
but this yes:
Code: Pascal  [Select][+][-]
  1.     if StreamIn[x].AACI.lwDataLen > (StreamIn[x].AACI.BitsPerSample div 8) then
  2.                 StreamIn[x].Data.outframes := trunc (int64(StreamIn[x].AACI.lwDataLen) Div (int64(StreamIn[x].AACI.
  3.                                               BitsPerSample) Div 8))          

[EDIT2] With this code, does it compile? (if yes I will commit it):
Code: Pascal  [Select][+][-]
  1.  if StreamIn[x].AACI.lwDataLen > (StreamIn[x].AACI.BitsPerSample div 8) then
  2.             StreamIn[x].Data.outframes := trunc(StreamIn[x].AACI.lwDataLen / (StreamIn[x].AACI.
  3.                                           BitsPerSample / 8))
       
« Last Edit: January 02, 2025, 01:50:33 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Josh

  • Hero Member
  • *****
  • Posts: 1446
Re: UOS Not Compiling on trunk (possible fix)
« Reply #2 on: January 02, 2025, 03:00:49 am »
Lazarus 4.99 (rev main_4_99-723-g6786a53330) FPC 3.3.1 i386-win32-win32/win64
Code: [Select]
    if StreamIn[x].AACI.lwDataLen > (StreamIn[x].AACI.BitsPerSample div 8) then
                StreamIn[x].Data.outframes := trunc (StreamIn[x].AACI.lwDataLen Div (StreamIn[x].AACI.
                                              BitsPerSample Div 8))
compiling to x86-64 get message
uos.pas(11077,47) Error: Can't determine which overloaded function to call
both lwDataLen and BitsPerSample are longword

trunc() defined as int64

compiling to x86 original is  fine.


Code: [Select]
if StreamIn[x].AACI.lwDataLen > (StreamIn[x].AACI.BitsPerSample div 8) then
            StreamIn[x].Data.outframes := trunc(StreamIn[x].AACI.lwDataLen / (StreamIn[x].AACI.
                                          BitsPerSample / 8))
compiles both x86 andx86-64




The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: UOS Not Compiling on trunk (possible fix)
« Reply #3 on: January 02, 2025, 03:16:37 am »
Lazarus 4.99 (rev main_4_99-723-g6786a53330) FPC 3.3.1 i386-win32-win32/win64
Code: [Select]
    if StreamIn[x].AACI.lwDataLen > (StreamIn[x].AACI.BitsPerSample div 8) then
                StreamIn[x].Data.outframes := trunc (StreamIn[x].AACI.lwDataLen Div (StreamIn[x].AACI.
                                              BitsPerSample Div 8))
compiling to x86-64 get message
uos.pas(11077,47) Error: Can't determine which overloaded function to call
both lwDataLen and BitsPerSample are longword

Hum, each commit more restriction  :-X...
So, if this code is ok:

Code: [Select]
if StreamIn[x].AACI.lwDataLen > (StreamIn[x].AACI.BitsPerSample div 8) then
            StreamIn[x].Data.outframes := trunc(StreamIn[x].AACI.lwDataLen / (StreamIn[x].AACI.
                                          BitsPerSample / 8))
compiles both x86 andx86-64

This (seems) to mean that "div" is less flexible in the latest fpc 3.3.1 trunk.
But I have to admit that in the original code, these "div" should not be used (but "/" instead for more precision) because of the trunc(theresult).
OK, let's use this code for uos.

Thanks Josh to note this and happy perfect year.

Fre;D
« Last Edit: January 02, 2025, 03:20:16 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018