简体   繁体   English

如何在.NET应用程序中执行C代码?

[英]How can I execute C code inside a .NET application?

I'm into Embedded Software development, and write pure C code which are hardware device dependent. 我从事嵌入式软件开发,并编写与硬件设备相关的纯C代码。

Before our hardware device gets ready, I need to complete application modules of our embedded software, which won't be directly hardware dependent. 在我们的硬件设备准备就绪之前,我需要完成嵌入式软件的应用程序模块,这些模块不会直接依赖于硬件。

Is there any way where I can write and execute C code in a .NET environment (VC++ or C#), have some UI for simulating the application, debug with breakpoints and watches and once the logic is proven, get the C files and port those to hardware (of course with modified interfaces)? 有什么方法可以在.NET环境(VC ++或C#)中编写和执行C代码,具有一些用于模拟应用程序的UI,使用断点和监视进行调试,一旦逻辑被证明,就可以获取C文件并将其移植硬件(当然具有修改的接口)?

Since I'm not an expert in .NET, I'm not sure if this can be done. 由于我不是.NET专家,所以我不确定是否可以这样做。 If yes, what approach do people use? 如果是,人们使用什么方法?

It is straight forward to link C and C++ code, just ask your favorite search engine, or the little search box at the top of this page. 链接C和C ++代码很简单,只需询问您喜欢的搜索引擎,或在页面顶部的小搜索框即可。

Be sure to put 一定要放

#ifdef __cplusplus
extern "C" {
#endif

and

#ifdef __cplusplus
}
#endif

around your declarations in the C header files. 在C头文件中的声明周围。

For C# I don't have personal experiences, sorry. 对于C#,我没有个人经验,对不起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM