假设我正在与 C 交互。
这是接口的包装函数。
@property extern(C) void onEvent(void function(InterfaceStruct*, int, int, int) nothrow callback)
{
interfaceSetCallback(handle, callback);
}
都好。
wrapper.onEvent = function void (InterfaceStruct*, int x, int y, int z) nothrow
{
if (x == 11) doSomething();
};
哦哦:
Error: function foo.bar.onEvent (void function(InterfaceStruct*, int, int, int) nothrow callback) is not callable using argument types (void function(InterfaceStruct* _param_0, int x, int y, int z) nothrow @nogc @safe)
因此,它希望我将函数文字设为 extern(C)。那么我该怎么做呢?我找不到任何办法这样做。