进入用C的64位应用程序转换32位应用程序 [英] Converting 32-bit Application Into 64-bit Application in C

查看:160
本文介绍了进入用C的64位应用程序转换32位应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是presently在做这个应用程序转换一个32位应用程序转换为64位应用程序在C目前正在对x86架构(在Windows,OSX,UNIX,LINUX)。因此,在开始编码之前,我想知道我需要什么,而转换应用程序来考虑。


解决方案

  1. 找到是谁写的。他们是白痴?难道他们的您从几年前的?你可以问他们问题吗?他们是熟悉的多个平台和系统的存在?知道的程序的将帮助您了解的问题,当你碰到他们的作者(S)的思维定式。

  2. 获取一个64位计算机/编译环境和运行。

  3. 与诠释长进行更换。要非常清楚,不是

  4. 替换(INT)及X 蒙上和打字使用intptr_t (无符号INT)及X uintptr_t形式

  5. 审核任何依赖于铸造结构,以的char * 做指针运算它。

  6. 正则表达式搜索\\ 4; \\>如果你假定 4 = sizeof的(无效*)

  7. 要有耐心。当你发现一个问题,看看其他地方是否存在同样的问题,并包装在宏观的解决方案。

  8. 尝试不使用 #IFDEF RUN64 或任何类似。你会后悔的,如果128位平台的不断进入流行。

  9. 封装所有的变化,那会掩盖其他地方的便携性差异在程序集中的一些宏条款。

  10. 使用的覆盖测试,以帮助确保你已经覆盖了一切(如适用)

修改的形式加入的评论所说 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.

解决方案

  1. 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.
  2. Get a 64-bit machine/build environment up and running.
  3. Replace long with int. Be perfectly aware that LONG is not long.
  4. Replace (int)&x casts and typing with intptr_t and (unsigned int)&x with uintptr_t
  5. Audit anything that relies on casting structures to char* to do pointer arithmetic with it.
  6. Regex search for \<4\> in case you assumed 4 = sizeof(void*)
  7. Be patient. When you find a problem, look elsewhere if the same problem exists, and wrap the solution in a macro.
  8. Try not to use #ifdef RUN64 or anything similar. You'll regret it if 128-bit platforms ever go into vogue.
  9. Encapsulate all of your changes in terms of some centralized macros that'll hide the portability differences elsewhere in your program.
  10. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆