为 32 位环境编程与为 64 位环境编程/构建配置 [英] Programming for a 32-bit environment vs programming for a 64-bit environment / Build configurations

查看:32
本文介绍了为 32 位环境编程与为 64 位环境编程/构建配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在查看一些具有多个构建配置(发布/调试、Win32/x64)的相同代码(一个示例 MS Visual Studio C++ 项目).

I was looking at some same code (a sample MS Visual Studio C++ project) recently with multiple build configurations (Release/Debug, Win32/x64).

我的问题:有什么区别?我想我了解Release/Debug(Release = 项目的最终版本,Debug = 用于在调试器中运行的版本),但是在为Win32/x64 平台构建不同版本时需要考虑哪些事情?是否存在任何编码差异,或者这是否仅影响相同代码最终构建到机器代码中的方式?

My question: What is the difference? I guess I understand Release/Debug (Release = finalized version of project, Debug = version used to run in debugger), but what things need to be considered when building different versions for Win32/x64 platforms? Is there any coding differences, or does this just affect how that same code is ultimately built into machine code?

我知道有不同的库文件取决于您使用的是 32 位还是 64 位系统...所有这些差异是否又只是机器代码?一个 32 位库文件和它对应的 64 位库文件会不会是两个具有完全相同功能的文件,这些文件最初是从相同的源代码构建的,只是它们的机器代码实现不同?

I know there are different library files depending on whether you're using a 32-bit or 64-bit system as well... Are all of these differences again just machine code? Would a 32-bit library file and its corresponding 64-bit library file be two files with exactly the same functions build from the same source code originally, and only differing in their machine code implementation?

谢谢!

--罗素

推荐答案

代码的编写方式可能会有所不同,但稍加注意,大多数代码都非常容易编写,因此它可以像32 位或 64 位可执行文件.大多数问题出现在/如果您假设 Windows 类型之间存在相似性(例如,DWORD 将保存一个指针——在 32 位代码中为真,但在 64 位代码中为真).

There can be differences in how the code is written, but with a bit of care most code is pretty easy to write so it compiles and runs fine as either a 32-bit or 64-bit executable. Most of the problems arise when/if you do things like assuming similarity between Windows types (e.g., that a DWORD will hold a pointer -- true in 32-bit code but not in 64-bit code).

另请注意,32 位编译器的最后几次迭代有一个警告,您可以为无法移植到 64 位执行的代码启用(而且它似乎非常有效和准确).

Also note that the last few iterations of the 32-bit compiler have had a warning you could enable for code that wouldn't port to 64-bit execution (and it seems pretty effective and accurate).

这篇关于为 32 位环境编程与为 64 位环境编程/构建配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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