string_operation.go (golang 函数)
//export AddString
func AddString(str string, v interface{}) bool {
somestrings = append(somestrings, str);
xyz.Compile(str, v)
fmt.Println("Added!!\n");
}
return true;
}
//export SearchString
func SearchString(str string) (v interface{}, ok bool) {
v, ok = xyz.Match(str);
if ok == true {
fmt.Println("Found!!");
} else {
fmt.Println("Not found!!");
}
return
}
导出以在 C 代码中使用时的上述 golang 文件
string_operation.h(导出的头文件)
typedef struct { const char *p; GoInt n; } GoString;
typedef struct { void *t; void *v; } GoInterface;
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
/* Return type for SearchStringValue */
struct SearchString_return {
GoInterface r0; /* v */
GoUint8 r1; /* ok */
};
extern struct SearchString_return SearchStringValue(GoString p0);
extern GoUint8 AddString(GoString p0, GoInterface p1);
现在的问题是如何在 C 代码中实现空接口{}?