C与C++之数据类型(一)

时间:2019-12-27
本文章向大家介绍C与C++之数据类型(一),主要包括C与C++之数据类型(一)使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

阿里P7移动互联网架构师进阶视频(每日更新中)免费学习请点击:https://space.bilibili.com/474380680

C++与C#数据类型总结

C#调用C++的DLL搜集整理的所有数据类型转换方式,可能会有重复或者多种方案。

Win32 Types —- CLR Type

Struct需要在C#里重新定义一个Struct
CallBack回调函数 需要封装在一个委托里,delegate static extern int FunCallBack(string str);
unsigned char ppImage** 替换成 IntPtr ppImage
int& nWidth 替换成 ref int nWidth
int, int&, 则都可用 ref int 对应
双针指类型参数,可以用 ref IntPtr
函数指针使用c++: typedef double (
fun_type1)(double); 对应 c#:public delegate double fun_type1(double);
char* 的操作c++: char* 对应 c#: StringBuilder
c#中使用指针:在需要使用指针的地方 加 unsafe

unsigned char对应public byte

 typedef void (*CALLBACKFUN1W)(wchar_t*, void* pArg);
 typedef void (*CALLBACKFUN1A)(char*, void* pArg);
 bool BIOPRINT_SENSOR_API dllFun1(CALLBACKFUN1 pCallbackFun1, void* pArg);

调用方式为

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void CallbackFunc1([MarshalAs(UnmanagedType.LPWStr)] StringBuilder strName, IntPtr pArg);

原文链接:https://blog.csdn.net/humanking7/article/details/50981922
阿里P7移动互联网架构师进阶视频(每日更新中)免费学习请点击:https://space.bilibili.com/474380680

原文地址:https://www.cnblogs.com/Android-Alvin/p/12109556.html