Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Intermediate
Apr 24, 2000

Porting Code to a Different Compiler

I receive many questions from readers asking for guidance on how to port an existing C++ app to a different compiler or platform. Porting software can be very easy or very difficult, depending on several factors. The most important one is the extent to which the software relies on non-portable or compiler-specific features. For example, if your code uses non-standard keywords such as __closure (in Borland's C++ Builder) and __int64, you will have to replace them with the equivalent keywords supported by target compiler. Using standard constructs that have the same semantics instead of proprietary keywords is even better.

Porting is more difficult if your app is based on a proprietary framework such as MFC or DCOM which your target platform, e.g., Unix, doesn't support. In situations like these, you need to perform code analysis and separate portable code components (e.g., business logic classes, financial and arithmetic functions, standard functions and classes) from non-portable GUI and platform API components. The portable components can be used as is on the target platform. As for the non-portable components—it's likely that your target platform offers a corresponding set of classes or API functions that you can use instead. For example, instead of the spawn() family of functions used in Win32, you can use the exec() or fork() functions in Unix and Linux. Sometimes, however, you will have to redesign parts of your app from scratch.

Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap