Relative Content

Tag Archive for gocgo

Marshaling memory between C and CGO (free/malloc)

I am working on a project where i have a C application that needs to call an sdk that is written in Go. We have created a wrapper DLL that we can invoke from our C application. However, the marshaling of non-primitives has me a bit stumped.

How to convert go pointer to c pointer

I’m newer to go and I’m trying to pass a pointer to some C code so that it can call a method with that pointer and I can access that pointer again. Here is a simple example of what I’m trying to do:

Does disabling GC make CGO callbacks safe?

I’m integrating a c library into my go program, and one of the functions I have to use have a callback interface. As is common with these, the function in question also takes a pointer, that it will pass you as a parameter when it calls the callback.

cgo: cannot parse $WORK/b046/_cgo_.o as ELF, Mach-O, PE or XCOFF

What’s the issue? I want to connect Go to NodeJS using napi-go. When I run go build -buildmode=c-shared -o “example.node” . this is the error I get: cgo: cannot parse $WORK/b046/_cgo_.o as ELF, Mach-O, PE or XCOFF Expected An “example.node” file should be created which can be required in the index.js file. Repository Here is […]