我试图弄清楚如何将一个简单的结构嵌入到另一个从 c# 传递给 C dll 的结构中。你如何编组嵌入式结构?精简到必需品。
//The C code
typedef struct {
int a;
int b;
} A;
typedef struct {
int c;
A myStruct;
} B;
//The c# code:
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class A{
int a;
int b;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class B{
int c;
public IntPtr A;
}