2

I got my hands on some well documented C++ code that's about 1KLOC. It would take me a significant amount of time to port this line by line and debug the results, so I'm wondering if there are tools or ways to do it faster, and I have questions in case I have to do it fully manually.

Specific questions:

  • Does C# also support overriding operators like * and +?
  • What to do with the C++ memory management code like alloc() and free()?
  • How to identify functions used from <stdio.h>, <conio.h> and <math.h>?
  • How to find replacements to such system functions?
  • Does C# have any special/open source libraries that provide such functions?

No graphics libraries have been used, its purely command line based.

Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607

3 Answers3

2

You might want to try this tool and see if that works out for you. There is a demo where you translate up to a 100 lines of code at a time:

http://tangiblesoftwaresolutions.com/Product_Details/CPlusPlus_to_CSharp_Converter_Details.html

Try it out and let us know. But it would prolly be more beneficial to port this yourself in c# so you can get a handle of the features that c# comes with.

MatthewJ
  • 3,127
  • 2
  • 27
  • 34
1

You will need to do it manually, and 1KLOC isn't much.
However, you will need to learn C#.

To answer your questions:

  • Yes
  • Depending on what you're doing, probably List<T>
  • I don't know what you're asking
  • Look in the .Net Framework class library on MSDN
  • Yes
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

1 - C# also support operator overloading see : http://msdn.microsoft.com/en-us/library/aa288467(VS.71).aspx (it looks very much to c++ operator overriding)

2 - C# is garbage collected so you only need "new" instead of alloc. free is done by the garbage collector

3 - I have no idea , but when porting code you would have to find in standard c# library the equivalents

4 - In MSDN there is a lot of information.

5 - ( http://code2code.net/ ) ??? but better to do it at hand


More information on coding standards : http://msdn.microsoft.com/en-us/library/xzf533w0.aspx ie naming: http://msdn.microsoft.com/en-us/library/x2dbyw72.aspx

pastjean
  • 1,307
  • 11
  • 21