Programming for a 32-bit environment vs programming for a 64-bit environment / Build configurations

亡梦爱人 提交于 2019-12-11 07:35:01

问题


I was looking at some same code (a sample MS Visual Studio C++ project) recently with multiple build configurations (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?

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?

Thanks!

--Russel


回答1:


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).

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).




回答2:


x32 runs a smaller footprint. "Words" are smaller (32bit vs 64bit). Generally, x64 bit operating systems are fantastic as they let apps use more than four gigabytes of RAM. However, unless you are using massive software like a database, 32x generally runs faster and more efficiently, especially on x64 bit operating systems.



来源:https://stackoverflow.com/questions/3002935/programming-for-a-32-bit-environment-vs-programming-for-a-64-bit-environment-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!