Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows development: x86 to x64 transition

Are there any guidelines how to transit to x64 with as little pain as possible?

Suppose, I have a windows native x86 executable written in C++. The EXE works fine by itself, but there is also DLL that is hosted by both, the former EXE and an outside x64 process. With setup like this, what parts would I need to rewrite?

I would appreciate a more general answer or maybe a link to a reference where some theoretical background is given. Thanks

like image 220
Kerido Avatar asked Dec 29 '22 23:12

Kerido


1 Answers

In general the approach I recommend is to Unit Test the hell out of it. Build up your tests so that they're all passing on the 32-bit implementation and then start building and testing on 64-bit. It's worth devoting particular attention to any parts of your code where you do any of the following:

  • Stream data across the network (especially for types such as size_t which will now be a different size. Go through this code and change things like size_t and long to explicit 32 or 64-bit typedefs)
  • Load/save binary data to file (ditto re: size_t/long)
  • Do bit-twiddling with hardcoded values such as 0xFFFFFFFF

There really are no shortcuts except to test as many code paths as you can. How easy the job will be will depend on how portably the code was written. You might be lucky...

like image 125
the_mandrill Avatar answered Dec 31 '22 13:12

the_mandrill