[go-nuts] Re: Freeing memory of a cgo library

2018-05-26 Thread Liron Levy
Hey Jake, Yes, i will probably go with the first option :) feel a bit massy but it is probably the better way to go... Plus in my case probably the only way hahaha. Thanks a lot for helping. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To u

[go-nuts] Re: Freeing memory of a cgo library

2018-05-26 Thread jake6502
FYI, the standard way around this is to expose a "free" method from your DLL for memory allocated by the DLL. The other way is to require that users of the DLL supply the memory in advance to functions needing it. These two methods are the ones used by the Windows libraries themselves. Pretty s

[go-nuts] Re: Freeing memory of a cgo library

2018-05-25 Thread Liron Levy
Gotcha :) Thanks for the info, guess i will have to find a way around it then. At least i now know there is no real way to do what i wanted so that close this door :) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this grou

[go-nuts] Re: Freeing memory of a cgo library

2018-05-25 Thread alex . rou . sg
Nope, not ATM. Go only works with gcc, even the dlls are made with gcc. There is a issue on that and it seems like there is some progress but it isn't clear when it will be usable. https://github.com/golang/go/issues/20982 Also note that even if Go uses msvc, you would still have issues freeing

[go-nuts] Re: Freeing memory of a cgo library

2018-05-25 Thread Liron Levy
Well it is kinda reoated as im in this mass because of go :) Anyway, is there anyway to use cgo with msvc? I actually run the cgo command from msvc cmd assuming the c part will be compiled with msvc. In addition as far as i know you can actually do that with visual studio if you put the /md (mu

[go-nuts] Re: Freeing memory of a cgo library

2018-05-25 Thread alex . rou . sg
Memory allocated by one C/C++ runtime must and can only be freed through the same runtime. This is not a Go/cgo problem, this is normal C/C++ behavior. So by mixing gcc and msvc there are at least 2 C/C++ runtimes. Even mixing different compiler versions might cause issues. On Saturday, 26 May

[go-nuts] Re: Freeing memory of a cgo library

2018-05-25 Thread Liron Levy
Hey Jake, First if all thanks for the willing to help. Cgo is the built-in tool in go of building c libraries (see: https://golang.org/cmd/cgo/) What I basically do is that I have a go code, which i build into c library (dll), i.e, i insert the go code onto the cgo mechine then get .h and .dll

[go-nuts] Re: Freeing memory of a cgo library

2018-05-25 Thread jake6502
Looks like you are on windows. I have worked a lot with windows, C/C++ and go, but never actually built a go dll. But, since no one else has picked this up, maybe I can help. 1. I'm not sure what "the cgo" library means here? Do you have this: cpp<->go(dll)<->c(cgo)? Or something else. 2. Ho