Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
我不知道有什么,因为这种翻译非常很难做。 您正在尝试将以非托管语言编写的代码转换为托管语言。 即使您能够翻译代码,几乎每个方法都会被标记为
不安全
,这首先会抵消迁移到 C# 的大部分好处。这似乎是一个坏主意 - 您应该考虑从头开始重写应用程序。
I am not aware of any as this kind of translation would be very difficult to do. You are trying to translate code that was written in an unmanaged language into a language that is managed. Even if you were able to translate the code you would have almost every method marked as
unsafe
which would negate most of the benefits of moving to C# in the first place.This seems like a bad idea - you ought to be thinking about rewriting the application from scratch.
我的建议是首先使用 C++/CLI 将 C++ 代码移植到托管环境。 一旦在托管世界中工作,就可以围绕它用 C# 构建新代码。 如果现有代码的某些关键区域正在积极更改,请考虑此时移植到 C#。
My suggestions would be to initially use C++/CLI to port over the C++ code to a managed environment. Once working in the managed world, build new code in C# around it. If there are key areas of the existing code that are actively changing, consider porting to C# at that point.
我认为没有任何 C++ 翻译引擎 -> C# 可以做的不仅仅是在样板代码上安全地输入一些内容(修复基本语法) - 因为 C++ 和 C# 中使用的框架根本不同,一旦翻译器必须处理指针算术等内容,您就会遇到问题像这样。
考虑到 C++ 的复杂语法以及你可以用它做的疯狂事情(想想 Boost),我想任何译者都会迟早会遇到严重的麻烦。 请参阅此博文了解一些替代建议。
I don't think any translation engine for C++ -> C# could do more than safe a bit of typing on boilerplate code (fix basic syntax) - as the frameworks used in C++ and C# are fundamentally different, and you will run into problems as soon as the translator has to deal with pointers arithmetics and stuff like this.
Given the complex syntax of C++ and the crazy stuff you can do with it (think Boost) I guess any translator would run into serious trouble sooner or later. See this blog post for some alternative suggestions.
Code2Code.net 明确指出
Code2Code.net explicitly states