我想在 WiringPi C 库中使用 mcp23017.c 中的函数创建一个 C #包装类。我将这个现有的 C# WiringPi WrapperClass用于其他功能。我想扩展这个包装类以使用 mcp23017 的函数。我尝试在包装器中创建一个具有一个函数的新类:
public class mcp23017
{
[DllImport("libmcp23017.so", EntryPoint = "myPinMode")]
public static extern void myPinMode(struct wiringPiNodeStruct *node,Int32 pin, Int32 mode);
}
但是我得到了 struct 元素的这些错误。
) expected.
; expected.
{ expected.
} expected.
Invalid token "*" in class struct or interface member declaration
我必须在包装类中定义一个结构吗?它是如何工作的?不熟悉这个,因为我是使用 C# 的新手。