I'm attempting to create a Go binding for the low level API of FMod Studio via Go and CGo. My package seems to compile, however the example program using it complains that the parameter I passed to one of the FMod functions is invalid. The two used FMod functions from fmod.h:
FMOD_RESULT F_API FMOD_System_Create (FMOD_SYSTEM **system);
FMOD_RESULT F_API FMOD_System_GetVersion (FMOD_SYSTEM *system, unsigned int *version);
This is possibly a type conversion, however I'm relatively new to Go and not quite sure what's wrong. Any help is appreciated.
Here's the FMod package:
package fmod
// #cgo darwin LDFLAGS: -framework fmod
// #cgo linux LDFLAGS: -lfmod -ldl
// #cgo windows LDFLAGS: -lfmod
// #include "fmod.h"
// #include "fmod_errors.h"
import "C"
var fmod *C.FMOD_SYSTEM
func Init() {
var version *C.uint
res := C.FMOD_System_Create(&fmod)
errCheck(res, "System_Create")
res = C.FMOD_System_GetVersion(fmod, version)
errCheck(res, "version")
println(C.GoString(C.FMOD_ErrorString(res)))
}
func errCheck(result C.FMOD_RESULT, msg string) {
if result != C.FMOD_OK {
println("Audio Error: "+msg)
}
}
The test program:
package main
import("fmod")
func main() {
fmod.Init()
}