我有一堆外部C函数在C#中成为这样的东西:
public extern static int clGetDeviceInfo(
IntPtr device,
uint param_name,
IntPtr param_value_size,
void* param_value,
out IntPtr param_value_size_ret);
Run Code Online (Sandbox Code Playgroud)
因为有一堆看似相似的函数,我想创建一个读取这些C函数提供的数据的方法.这就是我的用途:
unsafe public static ErrorCode GetInfoString(
IntPtr handle, uint property,
Func<IntPtr, uint, IntPtr, void*, IntPtr, int> infoFunc,
out string value)
{
// reading logic
}
Run Code Online (Sandbox Code Playgroud)
我的问题是C#不允许我使用它void*作为泛型参数Func.有没有解决这个问题的方法?
我既不能改变外部C函数的签名也不能改变C#函数的签名(我正在使用库).