Using CBTREE with C++


The CBTREE function library was developed in standard C. In order to use it with C++, all CBTREE headers must be included using the extern "C" modification (see Listing 1) .

The code presented in this article was compiled using Borland's C/C++ 3.1 compiler. In my hands, the CBTREE library was originally compiled using Borland's Turbo C 2.0. While preparing this article, I retrieved the original distribution disks and recompiled the CBTREE library programs using Borland's C/C++ 3.1 compiler rebuilt the library. I recompiled and linked an application using the code presented here using the newly rebuilt library. Aside from a small reduction in the size of the library, I saw no change.

To successfully compile and link my programs, I had to make one change to the original CBTREE code. In the main header file, CBTREE.H, there is a superfluous declaration for function lockunlk (line 142) that does not include the argument list prototype. In C mode, the Borland compiler ignored this. In C++ mode, the compiler interpreted this as an overloaded function declaration and refused to continue because of the extern C modification. Removing the declaration (I commented mine out) made everybody happy.