C++ 到 C# 转换器

发布于 2024-07-13 07:58:04 字数 1539 浏览 5 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我一直都在从未离去 2024-07-20 07:58:04

我不知道有什么,因为这种翻译非常很难做。 您正在尝试将以非托管语言编写的代码转换为托管语言。 即使您能够翻译代码,几乎每个方法都会被标记为不安全,这首先会抵消迁移到 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.

赤濁 2024-07-20 07:58:04

我的建议是首先使用 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.

与他有关 2024-07-20 07:58:04

我认为没有任何 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.

沒落の蓅哖 2024-07-20 07:58:04

Code2Code.net 明确指出

您承认此页面只完成了一半的工作。

...

在大多数情况下,翻译后的代码甚至无法编译。

Code2Code.net explicitly states

You accept that this page does only half the work.

...

In most cases, the translated code will not even compile.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文