Turbo C is still a very useful IDE even today. In this post, we will take a look at this great IDE from the 90s.
I have to admit, I was never a heavy user of Turbo C back in the day. My journey as a programmer started with Turbo Pascal, followed by QBASIC, and then Microsoft Visual Basic 3.0. Although I did have Turbo C 3.01 installed alongside with Turbo Pascal on my Tandy 1000 at the time, it was not until many years later that I began to play with Turbo C extensively, as part of an embedded system project at work.
Recently, with some free time, I downloaded Turbo C and Turbo C++ from winworldpc and played with them on NTVDMx64. A “
Hello World” program runs well on Turbo C 1.0, just as it should on a modern compiler:
Obviously, one could point out many limitations with such an early IDE. There is no syntax highlighting and no way to set a breakpoint. Online help is available but limited to IDE usage only and does not cover C language syntax.
The “Edit” menu seems annoying as it doesn’t seem to do anything (no submenus, etc.) except to set the cursor to the edit window. This useless menu remained in Turbo C 2.0 and Turbo Pascal 5.5 and was only finally replaced with a full menu supporting Cut/Copy/Paste starting from Turbo C 3.0 and Turbo Pascal 6. Despite the useless “Edit” menu, the editor supports features such as block select, find, and replace using Wordstar shortcut keys, for example Ctrl-Q-F to find and CTRL-Q-A to replace. Most of these shortcut keys are described in online help:
And yes, online help refers to help text which is bundled with the software package (e.g., floppy disks), and not from the Internet as many would assume. At the time, due to limited storage capacity, most software came with hard-copy manuals and online help was considered quite an achievement. Visual Studio 2008 also had “online” help (installed via the MSDN Library CD) and contains extensive documentation of the C language (among others) – you can just place the cursor on a C function and press F1. In newer versions of Visual Studio, language help is simply provided by pointing the browser at the relevant MSDN page.
As the IDE files are dated 6 July 1987 and ANSI-C was not finalized until 1989 (referred to as C-89), many features taken for granted in modern C compilers are not available. For example, single line comments such as:
are not accepted and will produce an “expression syntax” error. Obviously, more modern features such as binary notation (0b10101010) are also not accepted either – you must use hex notation, e.g. 0xAA instead. Even Visual Studio 2008 does not support this as binary notation is part of C++ 14 and is only supported from Visual Studio 2015 or later. I wonder how many things the modern software developer is taking for granted nowadays.
In Turbo C 1.0, declaring function parameter types is optional and int will be assumed. The following would compile and work properly:
void test(a, b)
a = 4;
b = 5;
printf("%d %d\n", a, b);
The following would still compile but would cause undefined behavior (most likely a hang or crash) due to stack imbalance as the Turbo C compiler fails to detect that the required parameters are not provided:
void test(a, b)
a = 4;
b = 5;
printf("%d %d\n", a, b);
The following will cause a compile error (too few parameters) – Turbo C correctly detects missing parameters if the parameter types are declared:
In Turbo C 2.0, Borland added support for breakpoints and online help for C language. Place the cursor on a word and press Ctrl-F1 to get relevant help. Online help still does not contain code examples (which were finally added in Turbo C 3.0). The IDE color theme is now yellow-on-blue:
Obviously, you can’t set a breakpoint in a comment or on lines which otherwise produce no codes (e.g., declaration without initializers). If you do this in a modern IDE like Visual Studio, the breakpoint will be automatically moved to the next accepted line. If you do this with Turbo C, a message (Invalid Breakpoint, Ignore, Erase, Clear all bad, Skip all bad) will be shown the next time the code is run:
A PhD in computer science working at my office once tried to do exactly this for Visual Studio and complained that the IDE is buggy. Don’t get me into this.
Turbo C 2.0 also supports graphics using Borland Graphics Interface (BGI). You can get a demo of the supported features by running BGIDEMO.C:
If the code doesn’t compile, check Options > Directories and make sure that the path is set correctly (e.g., C:\TC\INCLUDE for the include directories). Also check Options > Linker and turn on linking for Graphics Library. The Turbo C installer set these values upon installation, but if you later moved the TC directory, these paths must be manually changed:
As with these early IDEs, code can be compiled and run without ever saving the file to disk! One must press F2 every time, else data will be lost if the computer needs to be restarted. I believe the feature is designed to avoid excessive floppy disk writes. This behavior is also true for Turbo Pascal. However, Free Pascal, a Turbo Pascal clone, prompts the user to save the file before the first compilation and auto-saves during subsequent compilation.
In Turbo C/C++ 3.0, syntax highlighting and code examples are added:
An option to show 43 lines for EGA and 50 lines for VGA is also added to Options > Preferences:
I seldom use this feature on a physical PC, because character height is shrunk (to cater for more lines) making the text hard to read:
However, on an emulator, this can be useful as the window height is now expanded and more lines can be displayed, but not at the expenses of character height. Here is a screenshot in 50 lines mode of the help window describing the “auto” keyword arguably the most useless keyword in the C language:
According to the above help text, having a local lifetime is the default for local variables and therefore the auto keyword is rarely used. If so, when do you need to use this keyword? I leave this as an exercise for the reader.
Turbo C 3.0 also has support for mouse, windowed editing, debug watches and projects, features we are all too familiar with on a modern IDE. To go to a function declaration, use Search > Locate function, which only works after your code has been successfully compiled. Except for auto-complete which is useful for complicated projects, the IDE is considered quite matured.
Free Pascal IDE tried to implement auto-completion, which is rather limited and only works for certain keywords (procedure, begin, end, repeat, etc.) and does not work for function parameters. The list of available keywords can be configured in Options > Environment > CodeComplete:
Turbo C 2.0 was the last version to run on a 8088. Later versions required protected mode (e.g., at least a 80286) but the compiled executables can run on a 8088 (with the correct linker settings). The libraries CONIO.H and DOS.H which contain several useful functions such as
delay() work well even on modern machines and do not suffer from Runtime Error 200 like the CRT unit of Turbo Pascal. I previously used Turbo C to develop a MIDI player for the PC XT, see this article for details.
Various games such as Commander Keen in Keen Dreams were also developed using Turbo C. I once studied the code for this game and realized that it has several macros to enable or disable support for Disney Sound Source. For example, inside id_sd.c, around line 1494, you can see that the original detection routine which also covers Sound Blaster and Disney Sound Source has been disabled, leaving only support for Adlib and PC speaker:
#if 0 // DEBUG - hack for Keen Dreams because of no space...
sd = sdm_SoundBlaster;
else if (SoundSourcePresent)
sd = sdm_SoundSource;
else if (AdLibPresent)
sd = sdm_AdLib;
sd = sdm_PC;
sd = sdm_AdLib;
sd = sdm_PC;
However, once enabled, only random sounds could be heard as the actual audio samples meant to be played on a Disney Sound Source device were never ready, explaining the reasons why these codes were commented out. No changes in audio will be noted if Sound Blaster detection is enabled. The Sound Blaster is backwards compatible with Adlib and the game simply plays Adlib sound as there is no specific support for Sound Blaster, apart from the auto-detection. You can try it yourself by downloading the codes from the above Github repository and use Project > Open Project to open KDREAMS.PRJ project file.
If you use Turbo C to interface with the parallel port, like what I did, take note that the correct function to use is
outb) from DOS.H. Unlike Turbo Pascal, there are no
PORTW arrays, and no
MemL arrays to provide direct access to real mode memory (e.g.
MEM[segment:offset]). To do the same, you will need to cast the address literal as a pointer and access the port using this pointer:
char* pointer = (char*)0x1173000; char value = *pointer;
char first_byte = pointer;
char second_byte = pointer;
All in all, Turbo C is still a very useful IDE even today. I believe it is still being used by some Indian schools to teach students the basics of C language. It does not have features like autocomplete which is not really necessary and could undermine early learning efforts. No, I am totally against old-school professors who ask students to write hundreds of lines of codes on paper for a final exam, but remembering the basic syntax of
strcpy() is certainly needed if one is ever going to be a good C developer. In any case, if you can’t write a program which (let’s say) displays the first 100 prime numbers with Turbo C, Visual Studio 2022 is not going to help you either. In my case, Turbo C is presently being run on an old machine to develop a modern-day emulator for an old piece of hardware, and the IDE has so far not disappointed me.
Since 2008, ToughDev has been publishing technical sharing articles on a wide range of topics from software development to electronics design. Our interests include, but are not limited to, Android/iOS programming, VoIP products, embedded design using Arduino/PIC microcontrollers, reverse-engineering, retro-computing, and many others. We also perform product reviews, both on new and vintage products, and share our findings with the community. In addition, our team also develops customized software/hardware solutions highly adapted to suit your needs. Contact us for more information.