的Windows开发:86到64位的过渡Windows

2023-09-08 10:29:57 作者:何必讨好

有没有指引如何转运到x64用尽可能少的痛苦越好?

Are there any guidelines how to transit to x64 with as little pain as possible?

假设,我有一个Windows原生x86可执行的C ++编写的。该EXE很好地独立工作,但也有由两个托管的DLL,前者EXE和外部的x64处理。通过设置这样的,我需要重写哪些部分?

Suppose, I have a windows native x86 executable written in C++. The EXE works fine by itself, but there is also DLL that is hosted by both, the former EXE and an outside x64 process. With setup like this, what parts would I need to rewrite?

我会AP preciate更普遍的答案,或者一个链接到一些理论背景,给出一个参考。谢谢

I would appreciate a more general answer or maybe a link to a reference where some theoretical background is given. Thanks

推荐答案

在一般的方法,我的建议是进行单元测试的地狱吧。建立你的测试,让他们都通过对32位实现,然后开始构建和测试的64位。这是值得给予特别关注您的code,你做任何以下的任何部分:

In general the approach I recommend is to Unit Test the hell out of it. Build up your tests so that they're all passing on the 32-bit implementation and then start building and testing on 64-bit. It's worth devoting particular attention to any parts of your code where you do any of the following:

在网络(尤其是对类型的数据流,如为size_t 现在将是一个不同的大小,通过这个code和改变的东西像为size_t 来显式的32位或64位的类型定义) 在加载/保存二进制数据保存到文件(同上重:为size_t /长) 请位变换硬codeD值,如0xFFFFFFFF的 Stream data across the network (especially for types such as size_t which will now be a different size. Go through this code and change things like size_t and long to explicit 32 or 64-bit typedefs) Load/save binary data to file (ditto re: size_t/long) Do bit-twiddling with hardcoded values such as 0xFFFFFFFF

真的有,除了测试尽可能多的code的路径,你可以没有捷径可走。如何轻松的工作将是将取决于可移植的code编写的。你可能是幸运的......

There really are no shortcuts except to test as many code paths as you can. How easy the job will be will depend on how portably the code was written. You might be lucky...