进入用C的64位应用程序转换32位应用程序 [英] Converting 32-bit Application Into 64-bit Application in C
本文介绍了进入用C的64位应用程序转换32位应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是presently在做这个应用程序转换一个32位应用程序转换为64位应用程序在C目前正在对x86架构(在Windows,OSX,UNIX,LINUX)。因此,在开始编码之前,我想知道我需要什么,而转换应用程序来考虑。
解决方案
- 找到是谁写的。他们是白痴?难道他们的您从几年前的?你可以问他们问题吗?他们是熟悉的多个平台和系统的存在?知道的程序的将帮助您了解的问题,当你碰到他们的作者(S)的思维定式。
- 获取一个64位计算机/编译环境和运行。
- 与诠释长进行更换。要非常清楚,
长
不是长
。 - 替换
(INT)及X
蒙上和打字使用intptr_t
和(无符号INT)及X
与uintptr_t形式
- 审核任何依赖于铸造结构,以
的char *
做指针运算它。 - 正则表达式搜索\\ 4; \\>如果你假定
4 = sizeof的(无效*)
- 要有耐心。当你发现一个问题,看看其他地方是否存在同样的问题,并包装在宏观的解决方案。
- 尝试不使用
#IFDEF RUN64
或任何类似。你会后悔的,如果128位平台的不断进入流行。 - 封装所有的变化,那会掩盖其他地方的便携性差异在程序集中的一些宏条款。
- 使用的覆盖测试,以帮助确保你已经覆盖了一切(如适用)
的修改的形式加入的评论所说 uintptr_t形式
注意:
I am presently working on converting a 32bits application into a 64bits application in C. This application is currently working on x86 architecture (Windows, osx, Unix, Linux). So, before starting coding, I wanted to know what do I need to consider while converting the application.
解决方案
- Find out who wrote it. Are they an idiot? Are they you from a few years ago? Can you ask them questions? Are they familiar with the existence of multiple platforms and systems? Knowing the mind-set of the author(s) of the program will help you understand problems when you run into them.
- Get a 64-bit machine/build environment up and running.
- Replace long with int. Be perfectly aware that
LONG
is notlong
. - Replace
(int)&x
casts and typing withintptr_t
and(unsigned int)&x
withuintptr_t
- Audit anything that relies on casting structures to
char*
to do pointer arithmetic with it. - Regex search for \<4\> in case you assumed
4 = sizeof(void*)
- Be patient. When you find a problem, look elsewhere if the same problem exists, and wrap the solution in a macro.
- Try not to use
#ifdef RUN64
or anything similar. You'll regret it if 128-bit platforms ever go into vogue. - Encapsulate all of your changes in terms of some centralized macros that'll hide the portability differences elsewhere in your program.
- Use a coverage tester to help make sure you've covered everything (if appropriate)
EDIT added uintptr_t
note as suggested by comment.
这篇关于进入用C的64位应用程序转换32位应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文