isola 1 Posted November 29, 2023 function TTVInitialsTest.CalcTestVariable({$IF CompilerVersion < 36} VarIndex : integer {$ELSE} VarIndex : NativeInt {$ENDIF}): double; begin Result:=0; if InRange(VarIndex, 1, NTestVariables) then if (VarIndex in [1 .. TV.Tracks.Count]) and (TV.SimSprocket[VarIndex]<>nil) then begin .................. .................. end; end; Hello everybody. This code compiles successfully in delphi 11. In Delphi 12 I have received an error in the line below ([dcc64 Error] E2010 Incompatible types: 'Integer' and 'Int64' ) if (VarIndex in [1 .. TV.Tracks.Count]) and (TV.SimSprocket[VarIndex]<>nil) then it's obvious that VarIndex and TV.Tracks.Count have the same type - NativeInt (TV.Tracks is descendant of TList) I don't understand. Where did I go wrong? Help, please. Share this post Link to post
FPiette 383 Posted November 29, 2023 (edited) 4 hours ago, isola said: it's obvious that VarIndex and TV.Tracks.Count have the same type - NativeInt (TV.Tracks is descendant of TList) Maybe your are wrong. With dcc64 compiler, Integer is 32 bits and NativeInt is 64 bits. Either define varindex as a NativeInt, or use a cast for count (You cannot have more that 2^31 index in that case). Edited November 29, 2023 by FPiette Share this post Link to post
isola 1 Posted November 29, 2023 Thank you, FPiette! The type of error confused me. Here, apparently the point is that the set size (255) is smaller than the type size (Lenght of the TList object). The code below contains potential error even in 32-bit code despite it can be compiled. Something like "Range check error" would have been more informative error message. VarIndex in [1 .. TV.Tracks.Count] Thanks again. Share this post Link to post
David Heffernan 2345 Posted November 30, 2023 All kinda moot since you'd never use set membership rather than InRange Share this post Link to post