Managed C++ to C# Conversion

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have some code that was written in managed C++ using VS 2005. I want to
convert that code into C#. Is there a tool available to do this?

Thanks in advance.
--

Shailen Sukul
Architect
(BSc MCTS, MCSD.Net MCSD MCAD)
Ashlen Consulting Service P/L
(http://www.ashlen.net.au)
 
Shailen Sukul said:
I have some code that was written in managed C++ using VS 2005. I want to
convert that code into C#. Is there a tool available to do this?

It is not guaranteed that such a conversion is possible.

Unlike the case with the other .Net languages of MS, when using C++/CLI or
Managed C++ it is possible to mix native and managed code in the same
application or even the same module.

That's not possible with C#, say.

If the person who chose managed C++ was being rational when he made the
decision that flexibility very well may have been the deciding factor which
means you may be looking at more than simple syntax conversion.

Regards,
Will
 
David Anton said:
There is no utility that converts C++/CLI to C#. We make a converter for
the
opposite direction, but in general it is not feasible to make a converter
which converts from a complex language (C++) to a simple language (C#).
This
is why you don't see any (good) converters available which convert from
C++
to any other language.

Actually, several of the best C++ compilers do convert to other languages,
either assembly or C, for which an optimizing compiler is already written.
 
Shailen Sukul said:
Thanks for reply.
Say, for arguments sake, that the C++ does not use unmanaged code. Is
there
a utility that will allow me to do a straight code conversion to C# from
C++
Managed code ?

If it was compiled as managed code (unlikely because the MC++ compiler
didn't let you control that), you can just decompile the MSIL with
Reflector.

If it's C++/CLI, then compile with /clr:pure and run Reflector on the
result. With MC++ not even that can save you, because I don't think you can
specify both /clr:pure and /clr:oldStyle at the same time.
 
Right - but they do not convert to simple high-level languages such as C#.
Obviously, a 'conversion' to assembly is done (or to C), but that's a
completely different thing than converting to C# or VB, for instance. Just
try converting a rat's nest of C++ macros and includes to C#.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
 
David Anton said:
Right - but they do not convert to simple high-level languages such as C#.
Obviously, a 'conversion' to assembly is done (or to C), but that's a
completely different thing than converting to C# or VB, for instance.
Just
try converting a rat's nest of C++ macros and includes to C#.

Am I allowed to use goto? And put everything in the main function? You're
right of course that the output isn't very human-friendly (not even
hacker-friendly), but the target language really only affects performance
and ABI.

As far as "rat's nest of macros and includes" are concerned, there's the
C/C++ preprocessor that does source->source comversion that is still quite
human friendly.
 
Back
Top