Integer() 类型转换在 Delphi 64 位上不起作用
我有以下代码:
inc(integer(DestPixel), DestDelta); //DestPixel: PColorRGB; DestDelta: integer;
这在 32 位平台上运行良好。如果我在编译器中将平台更改为 64 位,编译器会发出以下错误:
E2064 左侧无法分配给
问题似乎出在 integer()
类型转换中。我该如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 64 位平台上,
DestPixel
为 8 字节宽,Integer
为 4 字节,因此类型转换无效。您可以使用NativeInt
来解决此问题。NativeInt
类型与指针大小相同,因此根据输出目标在 4 字节到 8 字节宽之间浮动。话虽如此,我个人会使用
PByte
进行类型转换,因为它更正确地描述了您正在执行的操作。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 usingNativeInt
instead.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.