Since fbc version 1.10.0 , the 2 examples (from the 2 links above) produce a compile error.

  • It seems that the compile error is triggered as soon as a copy constructor is defined:
Type UDT
  Dim As Integer I
  Declare Constructor()
  Declare Constructor(Byref u As UDT)
End Type

Sub PassByVal (Byval u As UDT)
End Sub

Dim As UDT u
PassByval(Byval u)

C:.....\FBIDETEMP.bas(11) error 58: Type mismatch, at parameter 1 of UDT.constructor(as UDT) in 'PassByval(Byval u)'

  • Look at the special compile error produced when the copy-constructor is added by the compiler:
Type UDT
    Dim As String S
End Type

Sub PassByVal (Byval u As UDT)
End Sub

Dim As UDT u
PassByval(Byval u)

C:.....\FBIDETEMP.bas(9) error 58: Type mismatch, at parameter 1 (__FB_RHS__) of UDT.constructor(as const UDT) in 'PassByval(Byval u)'

 

Last edit: fxm (freebasic.net) 2024-03-20