On Tue, 21 Mar 2017 11:23:39 +0300 Konstantin Khomoutov <flatw...@users.sourceforge.net> wrote:
[...] Sorry, a couple of assorted fixes: > A sketch would look something like this: > > /* > typedef MediaHandle uint64_t Should be typedef uint64_t MediaHandle of course. > */ > import "C" > > import "unsafe" > > var media = map[uintptr]C.struct_Media > > //export GetMediaFromDB > func GetMediaFromDB(filename *C.char) unitptr { > c_struct_media := &C.struct_Media{} > > handle := uintptr(unsafe.Pointer(c_struct_media)) > media[handle] = c_struct_media > return handle > } This one is better formulated to return a value of proper type representing the handle: func GetMediaFromDB(filename *C.char) C.MediaHandle { c_struct_media := &C.struct_Media{} handle := C.MediaHandle(uintptr(unsafe.Pointer(c_struct_media))) media[handle] = c_struct_media return handle } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.