The error message 'expected declaration specifiers or '...' before '*' token' indicates a problem with the declaration of the callCallback function. The correct way to declare a pointer to a C string (*C.char) as a parameter is using C.char*. Additionally, the typedef keyword should be used for defining a function pointer type, not a function signature. Here's the corrected code:

typedef void (*Callback)(C.char*);

void callCallback(Callback callback, C.char* s);

In this corrected code, Callback becomes a function pointer type that accepts a C.char* parameter and returns void. The callCallback function then takes a Callback function pointer and a C.char* parameter.

C Go Interop: Fixing 'expected declaration specifiers or '...' before '*' token' Error

原文地址: https://www.cveoy.top/t/topic/pGXG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录