在c、c++中有typedef定义。当要把c/c++中的程序移植到c#或调用c中的dll函数时,涉及到一些数据结构的重新定义。为了方便,可使用c#中的using 别名;对于指针,需加unsafe
如:
using boolean_T = System.Byte;
unsafe public struct emxArray_real_T
{
double* data;
int* size;
int allocatedSize;
int numDimensions;
boolean_T canFreeData;
}
C#调用DLL文件时参数对应表(每一行的(1)(2)(3)(4)与列名前序号相符合)
(1)Wtypes.h中的非托管类型 (2)非托管 C语言类型(3)托管类名 (4)说明
(1)HANDLE (2)void* (3) System.IntPtr (4)32 位
(1)BYTE (2) unsigned char (3)System.Byte (4)8 位
(1)SHORT (2)short (3)System.Int16 (4)16 位
(1)WORD (2) unsigned short