Until now, pretty much everything I’ve built for Windows was compiled using Visual Studio 6, despite Microsoft having since released three newer versions. I thought it was about time I took a serious look at moving to Visual Studio 2005, as it makes building matching 32-bit and 64-bit versions far easier. The code it produces is measurably more efficient too, so what is there to lose?

Unfortunately, it’s not a simple matter of upgrading the project files and building new versions. The old C run-time DLL (MSVCRT.DLL) is available on Win95 (with IE4 installed) and later, but the new version (MSVCR80.DLL) is shipped only with Vista. It can be installed on older Win32 platforms, but only by using official vcredist_*.exe installers, which total almost 6MB for both x86 and x64 version. Ouch.

Fortunately, the run-time library can still be linked statically to remove the DLL requirement. Though that becomes less practical when done for many different modules in the same project. Another option is to leave out the run-time library altogether, though that’s really only suitable for small programs, or those specifically written to avoid it. Most of the missing functionality is available through compiler intrinsics and directly through the Win32 API (including string functions such as lstrlen, lstrcpy, etc.).

Unless we completely omit the CRT there’s yet another problem. VS2005 compiled binaries don’t work on Win95 or NT4, as the CRT startup code uses API functions (including IsDebuggerPresent) that don’t exist on those older versions of Windows. Attempting to launch the program gives a Windows loader error about the missing export, and the process is terminated.

There is a work-around for this, but it’s not particularly nice. It involves including two CRT source modules in the project, and using an alternative implementation of the missing function. The linker will then use these versions instead of the ones found in the static CRT library, so our module is 95/NT4 compatible once more.

I do now plan to use VS2005 where possible, with the approach depending on the size of project. SimCoupe has no option but to use the CRT, so I’ll link in the static version and use the Win95/NT4 work-around for backwards compatibility. SamDisk targets only Windows 2000 and later, but is designed to report a helpful message if run on older Windows versions. It doesn’t (currently) use the CRT at all, so using the new compiler is not an issue.