C++中结构体定义:
typedef struct // 平面
{
double time;
float normal[3];
float center[3];
} plane;
C++中方法声明:
public void GetPlanes(plane *planes, int size);
C#中结构体声明:
[StructLayout(LayoutKind.Sequential)]
public struct GPlane
{
public double timestamp;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public float[] normal;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public float[] center;
}
C#中方法声明:
[DllImport(LibFileName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern bool Pvr_getAirGlassPlanes([In, Out]GPlane[] plane, int size);
C#中调用该方法:
int size = 2;
GPlane[] plane = new GPlane[size];
Pvr_getAirGlassPlanes(plane, size);