简体   繁体   English

如何在ac#program中包含cpp头文件

[英]how to include cpp header files in a c# program

I am actually converting a cpp program into ac# dll. 我实际上是将cpp程序转换为ac#dll。 In cpp I have used some header files which contains some structs that are required. 在cpp中我使用了一些头文件,其中包含一些必需的结构。 I am creating a dll in C#. 我在C#中创建一个dll。 How do I link the header files in C#? 如何在C#中链接头文件? Can I build it as a static cpp library and link it to dll? 我可以将其构建为静态cpp库并将其链接到dll吗?

regards, shiksha 问候,shiksha

您不能直接在C#中使用C ++头文件,但我想,您可以很容易地将C ++结构转换为C#,因为我不知道您的特定结构类型。

as @keugyeol said You can't include the C++ headers in a C# application, you can convert the c++ structures to C# ones, this site for the interoperability between C# and C++ look at their implementation of the structs, the following attribute is commonly used 正如@keugyeol所说你不能在C#应用程序中包含C ++头文件,你可以将c ++结构转换为C#,这个站点为C#和C ++之间的互操作性看它们的结构实现,下面的属性是常用的

[StructLayout(LayoutKind.Sequential)]

http://www.pinvoke.net/ http://www.pinvoke.net/

but it is easier to convert the native c++ code to managed c++ and include your files, the output dll can be used in c#, or can be converted to C# using applications such ILSpy [that reverse the .Net Assembly in C# or VB Code] 但是更容易将本机c ++代码转换为托管c ++并包含文件,输出dll可以在c#中使用,或者可以使用ILSpy等应用程序转换为C#[在C#或VB代码中反转.Net程序集]

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

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