Closed tomwiel closed 3 months ago
I would have declared those types as you have, but Delphi 7, which is still supported by Image32, doesn't have POINTERMATH. I found the odd/unexpected array-indexing behavior of FPC while testing the code in FPC and changed the index variable from Integer
to NativeInt
, doing the sign extension for the FPC compiler. (I read through the FPC bug report and well, forcing one to use a workaround, is an interesting solution)
The code could be IFDEF'ed for Delphi 7-2006. I doubt that Image32 will drop those old Delphi versions. Using a PointerMath PByte instead of the "abomination" PByte = PChar
would remove all those Ord(b^)
.
This issue is found only in latest source (from July 7). Contrary to common practice over the last decades, negative index on static-array pointer (eg. buf[ index]) is unsupported by certain compilers (at least 64bit-FPC): To prevent wrong code generation, Range Checking can't be ignored on static array pointer. for reference: https://github.com/graphics32/graphics32/issues/51
If I reuse the existing type names, then supported alternative types look like this: (Range Checking can stay enabled):