Programming for a 32-bit environment vs programmin

2019-07-29 13:38发布

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

2条回答
Anthone
2楼-- · 2019-07-29 13:58

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.

查看更多
干净又极端
3楼-- · 2019-07-29 14:14

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

查看更多
登录 后发表回答