我正在将 C 代码移植到 C#,但我有一些疑问。
考虑这个结构:
typedef struct
{
uint32_t w;
uint32_t h;
uint32_t f_cc;
uint32_t st;
unsigned char *pl[4];
int32_t strd[4];
void (*done)(void *thisobj);
void *e_cc;
uint32_t rsrvd2;
uint32_t rsrvd3;
} f_tt;
我已经这样做了,但它不起作用(可能是因为它是错误的 :-/ ):
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct f_tt
{
public uint w;
public uint h;
public uint f_cc;
public uint st;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public Byte[] pl;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public int[] strd;
public delegate void done(IntPtr thisobj);
public delegate void e_cc();
public uint rsrvd2;
public uint rsrvd3;
}
有人可以告诉我如何做这个 ic# 吗?
void (*done)(void *thisobj);
void *e_cc;
谢谢!