CodeProject - Adapting old code to new realities
“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
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.
…
I missed this article when it first came out in November, 2010, but better late than never. I liked how it fairly methodically wakes us through the steps the author took in his real world porting of an existing C/C++ code to C#. We’re talking PInvoke, but actual code porting.
(via bitmiracle - Transforming C/C++ code to fully managed C# code.)
No comments:
Post a Comment
NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...
ALL comments are moderated. I will review every comment before it will appear on the blog.
Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...
I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...
Please see my comment policy for more information if you are interested.
Thanks,
Greg
PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...