Borland C++ v2.0 for OS/2

by Eric Slaats

If you've ever written a program for a personal computer in C, C++, Pascal or OO-Pascal it is very likely you have used a Borland Turbo compiler. The Turbo C and Turbo Pascal compilers for DOS are famous for their speed, performance and ease of use. The Windows version of Borland's C++ compiler as well as their (great) Delphi package (where is the OS/2 version, Borland?) are even better known and attract a lot of raves from the press. But what about the OS/2 version of the Borland C++ compiler?

Initial Impressions
The BCC set comes in slick blue and white Borland style box and contains a stack of manuals and a CD. This set only supports OS/2; it doesn't contain Windows (95/NT) or DOS support. For that you have to purchase a separate product. So if you want to do cross-platform development, you'll have to rely on OWL, Borland's Object Window Library (more on that subject later). Even worse, the Borland Windows compiler is better equipped than the OS/2 version and has a larger set of features.

Installation
The complete install of the BCC package requires about 60 Mb. However, it is very likely that you won't need to install all the features. If you've got the space, it pays to install all that's offered and take some time to play, though.

Installing BCC is a breeze. There is an easy interface which allows you to select the target drive and directory and the parts you would like to install. It will also make some changes to your config.sys (nothing major though - the PATH, LIBPATH, BOOKSHELF and HELP settings are changed so that they contain the BCC install directory and the IPF compiler and the PMREF (on-line help) environment variables are added). After the installation is completed, you'll find a Borland C++ folder on your desktop with all the installed items in it.

The Tools
The BCC package includes a wealth of tools. The most important (and probably most used) of them will be discussed in this article.

The IDE
Borland was one of the first companies to introduce what is now commonly referred to as an IDE (Integrated Development Environment) or IDDE (Integrated Development & Debugging Environment). An IDE contains everything in one interface that is needed to build an application. It has a built in compiler-debugger, an editor and an interface to maintain your projects. All this is wrapped in a good-looking multi-document interface.

To work with the Borland IDE, you've got to think in terms of projects. The IDE places all information that is needed to build an application in a binary project file (.PRJ). As an extra convenience, you don't have to write a make file. A project file contains a lot of information, all of which is used to build an application: Using the IDE is easy enough, just select open project from the project menu and give your project a name. The project settings are also very easy to change although the notebook contains about 40 pages and these look very intimidating at first.
 * Compiler settings
 * Linker and Make commands
 * Librarian settings
 * Paths for include files
 * List of all files (.CPP, .LIB, .RC, .H, etc.) that make up the project
 * Compilation statistics
 * The window size/position info for all the windows in the IDE
 * The cursor position of all the files open in the IDE
 * Editor colour/font settings

The settings pages include: The linker page: The default setting is for the linker to always include debugging information. This will enlarge your .EXE file and slow down compilation time. In my experience it is easier to set this debugging flag when you need to debug the code (despite the great speed of the compiler).

Another setting on this page that I strongly recommend changing is the "Image is based" flag. OS/2 guarantees that an .EXE can be loaded at 1000H. If the "Image is based" flag is set, the linker will use this as a base address. The resulting .EXE of this setting will have no internal fix ups, it will be smaller, load faster and use less memory. There is no downside, so I strongly suggest doing so.

The target page: In this page you can tell the compiler what kind of .EXE you're making. Most likely this is a PM executable. The default setting on my system was OS/2 .EXE. This means if you want to build a PM program, it won't run (I searched myself silly the first time).

The editor
The major part of the IDE is the editor. The Borland IDE contains a great editor; it has extensive syntax highlighting and a great way to handle indents. It can also be used when debugging and is tightly integrated with the compiler and the IDE toolbar. There is a very capable search function that can be used for regular searches, but it can also handle globals (all the variables in your program) and classes (very convenient). The disadvantage is that debugging information has to be linked with the .EXE to use these last two features (see the debugger).

The editor utilizes a popup with a number of items all targeted (except "save") at compiling and debugging. Personally I would have preferred a popup targeted at editing functions or a configurable popup.

The undo is also great, in fact, it's fairly limitless. Unfortunately the undo buffer is cleared when a file is saved. (Saving a file is needed in some cases to make sure you have up to date debugger information.)

The editor performs most functions quickly and without flaws. However, it's really a pity that it doesn't support drag and drop. D&D is really addictive once you get used to it (from packages such as Smalled and DragText). The editor could also do with a bookmark function for quickly jumping to various parts of your code (especially in larger files with a vast number of functions!).

And there is one other bug that is really annoying: the editor tends to drop newlines, especially after a paste function. The problem is that this doesn't show up on the screen (it does after saving and reloading though). Most times this won't be a problem, but if a statement line is appended after a comment-line (\\) that statement is lost! This leads to the most hard to find errors because the code looks OK.

Compiling
The IDE has a built in compiler that is very fast and very configurable. Besides that it produces relatively small .EXE files. If a project is compiled, the errors and warnings are placed in the Transcript window. This is where the IDE really shows its tight integration. If an error or warning is clicked, the window containing the source for this error becomes active and the line containing the error is highlighted. If the error isn't clear at once, you can get a hint by using the right mouse button on the error line in the transcript window and a popup menu allows you to call up help on the error.

If you're doing a large project it pays to split the project into a number of CPP files. This will speed up your work, since only the changed files will be recompiled. The existing .obj files from the other files in the project will be used by the linker.

Resource workshop The BCC compiler can handle (as can any OS/2 compiler) so called "resource" files. These files contain info about dialogs, menus, strings, help tables, etc. and they are compiled and added to your .EXE with the RC compiler (which is a standard OS/2 component). Resource files can be created with the Borland Resource Workshop.

The Borland Resource Workshop is a real gem and is very easy to use. Some of my programs, like SMEHTM (Smalled HTML Extensions), are almost completely created by using this collection of dedicated (sometimes graphical) editors. There are editors to create bitmaps and icons, text editors to create menus, help tables, string tables, etc., and a dialog editor where you can just click on a control in the floating toolbar and place it in the dialog where it can be shaped and configured.

The Resource Workshop also has the possibility to add (non-OS/2) Borland custom controls. These controls feature a set of push-buttons, checkboxes, group boxes and lines. To use these controls, a separate header file, as well as a library has to be included in your programs (which of course will make them more bulky). Unfortunately, the Resource Workshop doesn't support the newer OS/2 controls (yet) like the circular slider.

The debugger
The Borland debugger can be used from within the IDE or in a separate Debugger session. The functions for stepping through code, one line at the time, for setting breakpoints and for looking at variables (watches) are very slick. However I noticed that the debugger has a tendency to hang when multithreaded programs are being debugged (as do all the debuggers I have tried so far). The debugger has to be used with a little care, but overall it works great.

OWL
In version 2.0 of BCC for OS/2, Borland has included its Object Window Library. OWL is a package of routines (objects) that is very widely used by windows developers. It contains about 200 classes that should simplify the coding of OS/2 PM applications. This means that Windows programs written using OWL can very easily be ported to OS/2. In fact all that has to be done is recompile them (in most cases). OWL is great for programming on a more abstract plane, so you can think of simple (interface) structures. However, I found the learning curve for OWL to be rather steep. Besides that, with OWL, programs tend to grow large and slow and it's difficult to tell if you're effectively reusing code (which is what OO is all about). If you're not into object oriented programming it can be hard to master.

Documentation
Borland is very well known for its documentation. I find the DOS C++ manuals very good and the same is true of the manuals that come with the OS/2 package. More importantly, the Borland package also contains the IBM on-line documentation for all the APIs, messages, etc. This is a must read if you're serious about development. I find that I don't use the books at all, but do all my searching in the on-line documentation.

The files that Borland supplies on top of the IBM material are well written (although sometimes somewhat cryptic) and complete. However, if you're thinking about developing programs on a regular basis, I recommend the IBM Developers Connection CD. This will enable you to update your documentation in a regular fashion and it will give a lot of extra material.

The Borland package also contains a large set of example code. But don't get excited, it just won't do if you're a beginner; it's simply to complex. For beginners I'd strongly recommend EDM/2 as well as looking at some books. For the intermediate programmer though, it is a nice addition.

Concluding notes
I love the Borland compiler despite some of its flaws. It really is a shame that the Windows version is a lot better. Starting with Borland is easy and painless. It's simple to set up a project and have your first examples running in no time. The IDE, as well as the Resource Workshop, are great. And compile times are really short. If you're working like me, building a little code at a time or making code changes and trying them, this is definitely the compiler for you.