digitalmars.com                        
Last update Sun Mar 4 11:58:08 2018

Switching to Digital Mars C++ from Borland

This chapter describes the differences you should consider when converting code written for Borland C++ Version 4.0 to Digital Mars C++.

Keywords

Digital Mars C++ supports many of Borland C's nonstandard keywords. The following table lists Borland's extended keywords and their Digital Mars counterparts:

Table 24-1 Support for Borland nonstandard keywords
Unsupported Borland keywords Digital Mars counterparts
_cs __cs
_ds No equivalent
_es No equivalent
_saveregs No equivalent
_seg No equivalent
_ss __ss

Predefined Macros

Digital Mars C++ supports many of Borland C's nonstandard macros. The following table lists Borland's extended macros and their Digital Mars counterparts:

Table 24-2 Support for Borland C++ nonstandard macros
Unsupported Borland macros Digital Mars counterparts comments
__BORLANDC__ __DMC__ works the same, but version numbers are for DMC
__BCPLUSPLUS__ __DMC__ works the same, but version numbers are for DMC
__CDECL__ No equivalent  
__COMPACT__ __COMPACT__  
__DLL__ _WINDLL  
__HUGE__ No equivalent  
__LARGE__ __LARGE__  
__MEDIUM__ __MEDIUM__  
__MSDOS__ No equivalent  
__PASCAL__ No equivalent  
__OVERLAY__ No equivalent  
__SMALL__ __SMALL__  
__TEMPLATES__ No equivalent  
__TINY__ __TINY__  
__TCPLUSPLUS__ __DMC__ works the same, but version numbers are for DMC
__TURBOC__ __DMC__ works the same, but version numbers are for DMC
_Windows _WINDOWS  

Header Files

The Digital Mars C++ run-time library includes all the Borland non-standard headers. Many of these headers simply reference the Digital Mars header file that contains equivalent functions. Digital Mars C++ issues a warning whenever code uses a header file. In general, we recommend switching to ANSI-compliant headers wherever possible.

Library Functions

Digital Mars C++ supports most Borland library functions. The table below lists those Borland functions that the Digital Mars C++ run-time library does not support:

Table 24-3 Unsupported Borland library functions
Unsupported functions Borland header Comments
Graphics functions graphics.h  
Text display functions conio.h  
_dos_getvect dos.h  
_dos_setvect dos.h  
_harderr dos.h  
_hardresume dos.h  
_hardreturn dos.h  
_OvrInitEms dos.h  
_OvrInitExt dos.h  
_setcursortype conio.h Use display package functions
cgets conio.h Use display package functions
cprintf conio.h Use display package functions
cputs conio.h Use display package functions
closedir dirent.h  
cscanf conio.h  
dostounix dos.h  
farheapcheck alloc.h  
farheapcheckfree alloc.h  
farheapchecknode alloc.h  
farheapfillfree alloc.h  
farheapwalk alloc.h  
getpass conio.h  
getvect dos.h  
harderr dos.h  
hardresume dos.h  
hardreturn dos.h  
heapcheck alloc.h  
heapcheckfree alloc.h  
heapchecknode alloc.h  
heapfillfree alloc.h  
heapwalk alloc.h  
import dos.h  
importb dos.h  
intr dos.h  
opendir dirent.h  
outport dos.h  
outportb dos.h  
readdir dirent.h  
rewinddir dirent.h  
setvect dos.h  
unixtodos dos.h  

Some Digital Mars C++ run-time library functions have different types or numbers of arguments from their Borland counterparts, return different values, or support different defined constants. For information on specific functions see the Runtime Library Reference.

Borland Graphics Interface

Digital Mars C++ does not support any of the functions, fonts, or drivers in the Borland Graphics Interface.

Memory Models

The Digital Mars C++ implementations of those 16-bit memory models also supported by Borland C++ (the Tiny, Small, Medium, Compact, and Large models) are similar. Their significant differences include:

Huge memory model support

Digital Mars C++ does not support the Huge memory model. That is, a pointer whose type is unspecified cannot be made huge by default. However, the compiler supports huge pointers and huge data (via the huge modifier).

Digital Mars C++ does not support the Borland halloc and hfree functions. Convert calls to these functions to the corresponding Digital Mars far calls (which have unsigned long argument types and can, therefore, allocate huge blocks) or store the affected data in a different structure (a huge array, for example).

Assembly Language Interface

The Digital Mars C++ assembly language interface is very similar to Borland's. The only differences are:

Compiler Options

Digital Mars C++ provides a wide range of compiler command line options, many of which perform operations similar or identical to a Borland C++ compiler option.

To convert Borland compiler command lines to the most similar Digital Mars command lines possible, use the BCC utility. BCC automatically converts Borland C++ command lines to DMC command lines and then runs DMC.

Home | Runtime Library | IDDE Reference | STL | Search | Download | Forums