Damian Walker

Personal Web Pages

Trying Out C Compilers Again

Saturday, 4th November 2017

Over the past week I've picked up an old DOS game project I started over a year ago. This one will probably break the 64k limit for the Personal C Compiler, so I decided to use Turbo C 2.01.

Turbo C is one of the few decent compilers that will work on an XT system like my Hewlett Packard 100LX. It's not the most advanced system I could develop on, but it's nice to have a pocketable development system. For the time being, however, I'm starting development under DosBox on my laptop and desktop PCs.

After a week or so successfully compiling under Turbo C, the executable size approached 64k and I decided that it was a good time to move to a memory model that supported more (Turbo C defaults to a limited 64k memory model unless you say otherwise).

This is when my troubles began. A program that worked perfectly well in the small memory model froze under the large model. The program is doing nothing advanced with pointers - it's just malloc()ing memory for structures and strings, with the proper size and checks beforehand, and stuffing the data there. After some time debugging and Googling, and finding there's a distinct possibility of a compiler bug, I gave up on the compiler and started looking at another one.

A couple of years ago I'd tried out Watcom C, which looks well-documented and well-supported. But it won't run on an XT-class machine (though it generates code that will), so I'd ruled it out at the time. Given the limited nature of Personal C, and my problems with Turbo C, I've decided to revisit it and put aside the idea of pocketable C development.

There are quite a few advantages to Watcom C. It's a cross-compiler, so I can use comfortable Linux tools or its own Windows IDE to compile projects for DOS. Not only that, but it will compile for Windows and Linux too, so if I develop something entertaining for DOS, I might be able to easily adapt that to Windows and Linux.

If I continue to work on projects with Watcom C I'll no doubt add more blog posts about it in the future.