Passing void pointer to a C function

I am writing a cgo wrapper.
The C function which I need to call looks like

int my_c_func (void *obj, const char *name, int64_t val, int search_flags);

My wrppper function in golang looks like below:

func (ctx *Context) AvOptionSetInt(key string, value int64, flags int) int {
	Ckey := C.CString(key)

	return (int)(C.my_c_func((*C.void)((unsafe.Pointer)(ctx.priv_data)), Ckey, (C.int64_t)(value),

I am getting following error.
cannot use cgo0 (type *_Ctype_void) as type unsafe.Pointer in argument to Cfunc_my_c_func

I understand that golang does not have void * in golang but it is just typecasting to a C data structure.Can you please help me solve this problem?

The CGO documentation says:

The C type void* is represented by Go’s unsafe.Pointer.

So remove the (*C.void).

Thank you.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.