Porting Code to a Different Compiler

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.

See also  5 Ways to Improve Customer Experience

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist