Menu

Migrating_from_BC_to_VC

Migrating from Borland C++ 5.02 to Visual C++

This page describes the issues you may face when migrating code from Borland C++ 5.02 to Visual C++.



Compiler


Const checks

Modern versions of Visual C++ are much better than Borland C++ 5.02 at enforcing const-correctness of code. If your program was properly written, then no problems will be encountered, but if not, be prepared to have to correct it.


Exported functions

In Borland C++ a function exported from a DLL is declared as

void __export MFunc()

In Visual C++ it must be declared as

__export void MFunc()


Structured exception handling

In Borland C++ the construct is

try/__except

In Visual C++ it is

__try/__except

See Structured Exception Handling. Also, you cannot nest C++ exception handling with try/catch and SEH with __try/__except. See Compiler error C2713.


C/C++ Run-time library


MAXDIR, MAXFILE, MAXPATH, MAXEXT, MAXINT, etc.

Replace with the corresponding _MAX_DIR, _MAX_FNAME, _MAX_PATH, _MAX_EXT, INT_MAX, etc.


fnsplit and fnmerge

Replace with _splitpath and _makepath.

time_t type

In Borland C++ the following code works fine:

unsigned long mytime = time(NULL);
...
tm* pTime = localtime((time_t*)&mytime);

when compiled with Visual C++, the call to localtime returns nullptr, as time_t is defined as __int64. The workaround (if you really needed to store the time as unsigned long) is to first convert to a variable of type time_t and then to pass the address to localtime:

time_t t = static_cast<time_t>(mytime);
tm* pTime = localtime(&t);



Resources


Converting resource files

See Converting Borland C++ Resource Files to Visual C++.


Duplicate resources errors

See How do I resolve error "CVT1100 duplicate resource. type:STRING"?. Also, if the duplicate resource in the reported error is of type ICON and you have multiple resource files in the project, make sure that all ICON resources are defined in the same resource file.


Linker


Unresolved external errors for classes

If the project is split in multiple DLLs and the code in one DLL includes a header with a class declaration from a DLL further down the dependencies, if the class is not really used in this DLL, then it will link fine with Borland's linker, but Microsoft's linker will report that the class methods are unresolved externals. The solution is to replace the class header with simple class forward declarations, or to refactor the code to use a base interface for that class.


Borland Database Engine

For projects that use Borland Database Engine (BDE), the alternatives are:

Find a compatible version of IDAPI32.LIB
Add to the project a Visual C++ compatible version of IDAPI32.LIB. One place where it can be found is from this article: Accessing the Borland Database Engine (BDE) from Visual C++.
Use OWLFx library
Explore the now deprecated OWLFx library. It contains a class that directly loads IDAPI32.DLL and provides wrapper functions.
Upgrade to a different data access solution
In the long run, the best solution maybe to upgrade to a modern solution for handling data, for example SQLite.



Related

Wiki: Convert_Borland_C++_resource_files_to_Visual_C++
Wiki: Knowledge_Base
Wiki: Supported_Compilers
Wiki: Upgrading_from_OWL
Wiki: Upgrading_from_OWL_1.0

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.