Go bindings for bass.dll

I’m working on binding bass.dll ( https://github.com/lexesv/gobass.dll ) and ran into some difficulties.

I can not wrap these functions:

typedef BOOL (CALLBACK RECORDPROC)(HRECORD handle, const void *buffer, DWORD length, void *user);
HRECORD BASSDEF(BASS_RecordStart)(DWORD freq, DWORD chans, DWORD flags, RECORDPROC *proc, void *user);

I tried:

func RecordStart(freq int, chans int, flags int, proc RecordCallback) (int, error) {
    	h := C.BASS_RecordStart(C.DWORD(freq), C.DWORD(chans), C.DWORD(flags), (*C.RECORDPROC)(unsafe.Pointer(&proc)), nil)
    	if h != 0 {
    		return int(h), nil
    	} else {
   		return 0, errMsg(int(C.BASS_ErrorGetCode()))

type RecordCallback = func(handle C.HRECORD, buffer *C.char, length C.DWORD, user *C.char) bool

But while compiling example, I get errors:
./record.go:15: cannot use MyRecordCallback (type func(C.HRECORD, *C.char, C.DWORD, *C.char) bool) as type func(bass.C.HRECORD, *bass.C.char, bass.C.DWORD, *bass.C.char) bool in argument to bass.RecordStart

func main() {
 	fmt.Println(bass.RecordStart(44100, 2, 0, MyRecordCallback))
 	select {}
func MyRecordCallback(handle C.HRECORD, buffer *C.char, length C.DWORD, user *C.char) bool {
 	return true

Please, help me resolve issue how to properly wrap the callback functions.

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