All kinds of problems can occur when moving code from a 32-bit data environment to a 64-bit data environment. One common problem is that an 64-bit application that writes 32-bit values as 64-bit values. A 32-bit application accessing the same database will access the same data in 32-bits, with resulting errors.
It allows the running of any application regardless of its bit rate. The only difference between a hybrid core and a full 64-bit one is the inability to use more than 32 GB of RAM in the system. So at this moment there is absolutely no difference between loading in 32 and 64-bit modes.
Windows 10 64-bit is recommended if you have 4 GB or more RAM. Windows 10 64-bit supports up to 2 TB of RAM, while Windows 10 32-bit can utilize up to 3.2 GB. The memory address space for 64-bit Windows is much larger, which means you need twice as much memory than 32-bit Windows to accomplish some of the same tasks.
To run a 64 bit OS you need a 64 bit CPU and, if you are running a Mac, 64 bit-compatible firmware. (You also need enough RAM, obviously.)
As far as I'm concerned, the single most important thing about porting C/C++ code to 64-bit Windows is to test your application with MEM_TOP_DOWN
allocations enabled (AllocationPreference
registry value) as described in 4-Gigabyte Tuning:
To force allocations to allocate from higher addresses before lower addresses for testing purposes, specify
MEM_TOP_DOWN
when callingVirtualAlloc
or set the following registry value to 0x100000:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Memory Management\AllocationPreference
When does this matter?
/LARGEADDRESSAWARE
MSVC linker option (or which have the IMAGE_FILE_LARGE_ADDRESS_AWARE
flag set in their PE headers through other means, such as editbin.exe
), then they get a full 4 GB of virtual address space in 64-bit Windows, and you must test them with the AllocationPreference
registry value set.AllocationPreference
registry value set.AllocationPreference
registry value set.If your C/C++ application falls into one of these three categories and you don't test with MEM_TOP_DOWN
allocations, testing is very unlikely to catch any pointer truncation/signedness bugs in your code.
The second most important thing, if you use MSVC and you are recompiling C/C++ code for 64-bit, is to use the /Wp64
compiler option for your 64-bit build:
reinterpret_cast
or a C-style cast is used), as well as a few other 64-bit porting issues./Wp64
you should use a compiler that targets a 64-bit platform, but that alone will not catch pointer truncation/extension issues at compile time. Using a compiler that targets 64-bit and enabling the /Wp64
compiler option for the 64-bit build will catch many pointer truncation/extension issues at compile time, and this will save you time in the long run./Wp64
option is deprecated. I can see why the option is deprecated for 32-bit builds (where it is an evil hack that requires annotating many of your typedefs), but it's unfortunate that it is also deprecated for 64-bit builds (where it is actually useful).Articles:
20 issues of porting C++ code on the 64-bit platform
The forgotten problems of 64-bit programs development
64 bits, Wp64, Visual Studio 2008, Viva64 and all the rest...
Traps detection during migration of C and C++ code to 64-bit Windows
AMD64 (EM64T) architecture
And
Viva64 tool - for check 64-bit programs:
Viva64: what is it and for whom is it meant?
It might be easier to migrate .NET code if you have 100% "type safe managed code". You can just copy it to the 64-bit platform and run it successfully under the 64-bit CLR. Check this MSDN link on migrating 32-bit Managed code to 64-bit.
Btw, hanselman blogged about the topic recently.
If you are talking about 32-bit programs then you have practically nothing to worry about since Windows 64 will run them under emulation as 32-bit. Any problems with future Windows versions (e.g Windows 7) are likely to be incompatibilities rather than issues with a 64-bit OS.
However if your managed code is compiled for the "Any CPU" target platform and you make calls into unmanaged code (e.g PInvoke), or are dependent on other assemblies then there are some things to be aware of. Scott Hanselman's post about the x86/x64 CLR covers this and is a good explanation of the CLR on Win32/64.
When developing 64-bit native programs then the Programming Guide for 64-bit Windows is a good guide. It largely comes down to pointers and the size of data types :)
32bit programs will run fine on 64 bit windows. As long you are not doing any device driver kind of development of course.
If you compile your software as a 64 bit software the first time, you need to take care of following:
If you do DLL injection for any reason you will have trouble.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With