We have a 32-bit windows application which uses C++ and good old Windows application model. Is it technically possible to have a single source and compile it as 32 and 64 bit by say turning a compiler switch or using some macros?
Currently I don't think the code will compile as a 64-bit application, I'll have to fix the compilation errors, in general how should I proceed so that it compiles as both 64&32 bit app. What should I keep in mind? What will be the challenges? Any comments and tips will be appreciated. Thanks
Concerning "What should I keep in mind? What will be the challenges?" These are most common issues that I've encountered when porting code from 32-bit to 64-bit:
Make sure you use the most strict warning level when compiling (/W4
on microsoft's compiler or -Wall -Wextra -pedantic-errors
on gcc) to help catch conversions from a larger type to a smaller type.
Here is Microsoft's guide for porting, but is appropriate for other compilers as well.