Which one should I use to do 64 bit pointer math for Delphi, NativeUInt or NativeInt

Since there is a 64-bit delphi compiler, we must use 64-bit pointers.

so interesting, what's the difference if we use nativeint or nativeint. eg,

Should i use

Pointer(NativeUInt(Pointer(Buffer)) + LongWord(datawrote))^,

or

Pointer(NativeInt(Pointer(Buffer)) + LongWord(datawrote))^,

Does it matter? which is better style?

+4
source share
1 answer

The easiest way is to point to PByte. Then you can do arithmetic:

PByte(Buffer) + offset

This expression is of type PByte, so you may need to return it to another pointer type.

, , . , . PAnsiChar, PWideChar PByte, {$POINTERMATH ON}, .

+7

Source: https://habr.com/ru/post/1546313/


All Articles