在 C# 应用程序中使用 ANSI C 代码块
我们有一个使用 LEON2 处理器在嵌入式目标上运行的应用程序,该处理器是用 ANSI C 编写的。 我们似乎在计算校验和的代码中遇到问题,我想简单地将该函数复制到 C# 应用程序中来测试它。
我真的希望能够在这些行中做一些事情,这样我就可以真正拥有嵌入目标上的相同代码,而不是重写它并可能添加错误或以不同的方式执行它。
这可能吗?
We have an application that runs on an embedded target using a LEON2 processor which is written in ANSI C.
We seem to have an issue with the code calculating the checksum and I'd like to simply copy that function into a C# application to test it.
I'd really like to be able to do something in those lines so I could really have the same code that is on the embedded target rather than rewriting it and potentially adding errors or doing it differently.
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想简单地将该函数复制到 C# 应用程序中来测试它。
不幸的是,您不能。 C# 是一种托管语言,与本机 C 不同。因此,C# 不向后兼容 C/C++,并且您不能在 C# 应用程序中混合非托管代码。
我真的希望能够...拥有与嵌入式目标相同的代码,而不是重写它...
创建一个单独的 DLL,导出必要的函数并调用他们从那里。
I'd like to simply copy that function into a C# application to test it.
Unfortunately, you can't. C# is a managed language, unlike native C. C# is therefore not backward-compatible with C/C++, and you cannot mix unmanaged code in your C# application.
I'd really like to be able to ... have the same code that is on the embedded target rather than rewriting it ...
Create a separate DLL that exports the necessary function(s) and call them from there.