Thank you all guys for your replies! it helps me to understand how it 
works! really helpful! :)

On Friday, June 17, 2016 at 8:32:53 PM UTC+6, Andrey Salnikov wrote:
>
> Hello,
>
> Could you guys please help me. 
>
> I can't find how to export method function which belongs to some go-struct 
> to C-code (cgo part) as callback. I know how to export simple function 
> which not belongs to any type and use it as callback for C-function, but is 
> it possibly to export method of concrete struct instance? since I need 
> additional info when callback will be called from C-code. As example what 
> I'm trying to explain:
>
> // extern int goCallbackHandler(int, int);//// static int doAdd(int a, int b) 
> {//     return goCallbackHandler(a, b);// }
>
> import "C"
>
> type A struct {
> ... some data which used to process callback from C-side
> }
>
> // export cgo_callback
> func (a *A) cgo_callback(...){ <-----main problem here
> }
>
> main {
>    C.doAdd(...)
> }
>
> I can't modify c-side - I have only compiled library, so I don't know how 
> to identify which instance of struct should be used to properly process 
> C-call of go-side callback.
>
> Thanks,
> Andrey
>

-- 
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.

Reply via email to