本文介绍了如何迁移到德尔福2010年和统一code时,也prepare 64位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

64位支持预计不会在未来的版本,它不再是一个选项,以等待可能迁移现有code基地UNI code和一气呵成的64位。但是这将是很好,如果我们可以做我们的UNI code编译的时候就已经prepare我们code为64位。这将最大限度地减少事件影响,它最终将出现在2020年的版本。任何建议如何处理这个不引入得多混乱,如果它不到达,直到2020年?

As 64 bits support is not expected in the next version it is no longer an option to wait for the possibility to migrate our existing code base to unicode and 64-bit in one go.However it would be nice if we could already prepare our code for 64-bit when doing our unicode translation. This will minimize impact in the event it will finally appear in version 2020.Any suggestions how to approach this without introducing to much clutter if it doesn't arrive until 2020?

推荐答案

有another类似的问题,但我会重复我的答复在这里,以确保尽可能多的人看到这样的信息:

There's another similar question, but I'll repeat my reply here too, to make sure as many people see this info:

一起来,免责声明:虽然我的Embarcadero公司工作。我不能为我的老板说。我都快写是根据我自己的一个假设64位的Delphi应该如何工作的意见,但也有可能会或可能不会是竞争性的意见和其他预见或不可预见和不兼容导致替代设计决定进行的活动。

First up, a disclaimer: although I work for Embarcadero. I can't speak for my employer. What I'm about to write is based on my own opinion of how a hypothetical 64-bit Delphi should work, but there may or may not be competing opinions and other foreseen or unforeseen incompatibilities and events that cause alternative design decisions to be made.

这是说:

  • 有两种整数类型,NativeInt和NativeUInt,其规模将32位和64位的系统平台之间浮动。他们已经周围有不少的版本。没有其他的整数类型将改变大小根据目标的位数。

  • There are two integer types, NativeInt and NativeUInt, whose size willfloat between 32-bit and 64-bit depending on platform. They've beenaround for quite a few releases. No other integer types will change sizedepending on bitness of the target.

请确保所依靠铸造指针值到任何地方整数或反之亦然使用NativeInt或NativeUInt的整数类型。 TComponent.Tag应NativeInt更高版本的Delphi。

Make sure that any place that relies on casting a pointer value to aninteger or vice versa is using NativeInt or NativeUInt for the integertype. TComponent.Tag should be NativeInt in later versions of Delphi.

我建议不使用NativeInt或NativeUInt非基于指针的值。尽量保持你的code语义之间的32位和64位是相同的。如果您需要32位的范围内,用整;如果您需要64位,使用的Int64。这样,你的code应该运行在两个bitnesses相同。只有当你在铸造和某种形式的指针值,如引用或THandle,你应该使用NativeInt。

I'd suggest don't use NativeInt or NativeUInt for non-pointer-based values. Try to keep your code semantically the same between 32-bit and 64-bit. If you need 32 bits of range, use Integer; if you need 64 bits, use Int64. That way your code should run the same on both bitnesses. Only if you're casting to and from a Pointer value of some kind, such as a reference or a THandle, should you use NativeInt.

指针状的东西应该遵循类似的规则为指针:对象引用(明显),而且还像HWND,THandle等。

Pointer-like things should follow similar rules to pointers: objectreferences (obviously), but also things like HWND, THandle, etc.

不要依赖于字符串内部细节和动态数组一样,它们的头数据。

Don't rely on internal details of strings and dynamic arrays, liketheir header data.

我们的对64位API的变化总的政策应该是保持之间的32位和64位,其中有可能,即使这意味着相同的API64位的API不一定取机器的优点。对于例如,从TList可能只处理MAXINT格一下SizeOf(指针)元素,以保持计数,索引等为整数。由于整型不会浮动(即改变大小取决于位数),我们不想对客户的code连锁反应:任何索引的通过一个整数类型的变量,或循环指数往返式操作,将被截断并可能导致微妙的错误。

Our general policy on API changes for 64-bit should be to keep thesame API between 32-bit and 64-bit where possible, even if it means thatthe 64-bit API does not necessarily take advantage of the machine. Forexample, TList will probably only handle MaxInt div SizeOf(Pointer)elements, in order to keep Count, indexes etc. as Integer. Because theInteger type won't float (i.e. change size depending on bitness), wedon't want to have ripple effects on customer code: any indexes thatround-tripped through an Integer-typed variable, or for-loop index,would be truncated and potentially cause subtle bugs.

在哪里的API扩展到64位,他们将最有可能与完成一个额外的功能/方法/属性来访问额外的数据,这API也将在32位的支持的。例如,该长度()标准程序可能会返回整数类型的值参数输入字符串或动态数组;如果想处理非常大动态数组,有可能是LongLength()例程为好,其在32位实现是相同的长度()。长度()将抛出在64位的一个异常,如果施加到一个动态数组超过232元素。

Where APIs are extended for 64-bit, they will most likely be done withan extra function / method / property to access the extra data, and thisAPI will also be supported in 32-bit. For example, the Length() standardroutine will probably return values of type Integer for arguments oftype string or dynamic array; if one wants to deal with very largedynamic arrays, there may be a LongLength() routine as well, whoseimplementation in 32-bit is the same as Length(). Length() would throwan exception in 64-bit if applied to a dynamic array with more than 232elements.

与此相关,很可能会提高错误检查缩小操作中的语言,特别是缩小了64位值到32位的位置。这将创下分配的可用性返回长度值类型的整数位置,如果长度()返回的Int64。另一方面,特别为编译器魔像长度函数(),可能有截取的魔一些优点,以如交换机基于上下文的返回类型。但优势无法同样采取非魔法的API。

Related to this, there will probably be improved error checking fornarrowing operations in the language, especially narrowing 64-bit valuesto 32-bit locations. This would hit the usability of assigning thereturn value of Length to locations of type Integer if Length(),returned Int64. On the other hand, specifically for compiler-magicfunctions like Length(), there may be some advantage of the magic taken,to e.g. switch the return type based on context. But advantage can't besimilarly taken in non-magic APIs.

动态阵列可能会支持64位索引。需要注意的是Java的阵列仅限于32位的索引,即使在64位平台。

Dynamic arrays will probably support 64-bit indexing. Note that Javaarrays are limited to 32-bit indexing, even on 64-bit platforms.

字符串可能将被限制在32位的索引。我们有一个硬时间来到了现实的原因,人们希望4GB +字符串这真的是字符串,而不仅仅是管理的数据的斑点,对于这动态数组可以用来一样好。

Strings probably will be limited to 32-bit indexing. We have a hardtime coming up with realistic reasons for people wanting 4GB+ stringsthat really are strings, and not just managed blobs of data, for whichdynamic arrays may serve just as well.

也许一个内置的汇编,但有限制,比如不能够自由地与德尔福code混合;还有各地需要遵循在x64异常和堆栈帧布局规则。

Perhaps a built-in assembler, but with restrictions, like not being able to freely mix with Delphi code; there are also rules around exceptions and stack frame layout that need to be followed on x64.

这篇关于如何迁移到德尔福2010年和统一code时,也prepare 64位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 11:51
查看更多