Question

I have the following piece of code:

inc(integer(DestPixel), DestDelta); //DestPixel: PColorRGB; DestDelta: integer;

This works fine on 32-bit platforms. If I change the platform to 64-bit in the compiler the compiler emits this error:

E2064 Left side cannot be assigned to

The problem seems to be in the integer() typecast. How can I fix the problem?

Was it helpful?

Solution

On the 64 bit platform, DestPixel is 8 bytes wide, Integer is 4 bytes and so the typecast is invalid. You can fix this problem by using NativeInt instead.

inc(NativeInt(DestPixel), DestDelta);

The NativeInt type is the same size as a pointer and so floats between 4 bytes and 8 bytes wide depending on the output target.

Having said that, I personally would typecast with PByte because that more correctly describes the operation you are performing.

inc(PByte(DestPixel), DestDelta);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top