For details See ordinal types:
I did and it says:
Every platform has a ”native” integer size, depending on whether the platform is 8-bit, 16-bit, 32-bit or 64-bit. e.g. On AVR this is 8-bit.
So function Result should be SizeInt here and not Integer, right?
And also: Test for 64bit should be done with 4GB of used memory to detect things like this.
The result should be
NativeInt. As per my example.
No you don't need to test this with 4 GB of actual memory.
Just use my code and it will work on any (well, actually, most, there are some exotic exceptions) platform.
Explanation of my code:
Pointermath allows you to do calculations directly on pointers. This is also Delphi compatible, btw.
That means that the calculation is always correct for the pointer size of any platform.
Since on most platforms a pointer maps to a NativeUINT, but we want to allow for negative difference, we use a NativeINT.
This is safe because this particular calculation can never exceed range, So that code will work automatically correctly on most platforms.
That means that at least for 32 bit and 64 bit platforms the function will always return a valid value within range, regardless of the platform.