This article describes a useful technics for transforming old-style C/C++ code to fully managed C# code. These methods were used for porting classic libjpeg and libtiff libraries to .NET Framework
Table of contents
Introduction
1. Prerequisites
2. Transfer process
2.1 Removing the unnecessary code
2.2 Preprocessor and conditional compilation.
2.3 switch and goto operators
2.4 Time to gather stones
2.5 Preprocessor again and multiple inheritance
2.6 typedef operator
2.7. Pointer arithmetic
2.8 Function pointers
2.9 Isolation of the "problem code"
2.10 Changing compiler
2.11 Making it all work
Introduction
In this article I shall describe one of the methods that can be used to transform C/C++ code into C# code with the least amount of effort. The principles laid out in this article are also suitable for other pairs of languages, though. I want to warn you straight-off that this method is not applicable to porting of any GUI-related code.
What is this useful for? For example, I have used this method to port libtiff, the well-known TIFF library, to C# (and libjpeg too). This allowed me to reuse work of many people contributed to libtiff along with the .NET Framework Class Library in my program. Code examples in my article are taken mainly from libtiff / libjpeg libraries.
Read more: Adapting old code to new realities
Table of contents
Introduction
1. Prerequisites
2. Transfer process
2.1 Removing the unnecessary code
2.2 Preprocessor and conditional compilation.
2.3 switch and goto operators
2.4 Time to gather stones
2.5 Preprocessor again and multiple inheritance
2.6 typedef operator
2.7. Pointer arithmetic
2.8 Function pointers
2.9 Isolation of the "problem code"
2.10 Changing compiler
2.11 Making it all work
Introduction
In this article I shall describe one of the methods that can be used to transform C/C++ code into C# code with the least amount of effort. The principles laid out in this article are also suitable for other pairs of languages, though. I want to warn you straight-off that this method is not applicable to porting of any GUI-related code.
What is this useful for? For example, I have used this method to port libtiff, the well-known TIFF library, to C# (and libjpeg too). This allowed me to reuse work of many people contributed to libtiff along with the .NET Framework Class Library in my program. Code examples in my article are taken mainly from libtiff / libjpeg libraries.
Read more: Adapting old code to new realities