CGO中处理C中的回调函数
假设有以下 C语言的接口
api.h
#ifndef API_H
#define API_H
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*IntCallback)(void *, int);
void SetIntCallback(IntCallback cb, void *data);
void DoIntCallback(int value);
#ifdef __cplusplus
}
#endif
#endif
此时如果我们想要通过CGO来将上述的两个(尤其是设置回调函数的SetIntCallback
)导入到gol