CGo: How to get a pointer to a C function?

Written by
Link to Post by 

Hi, there’s a C library which has a function, say foo() that takes a pointer to a function (a C function, naturally) as one of the arguments. In the same library there’s a function bar() address of which I need to pass to foo(). Can this be done from Go? So far I wasn’t able to do this since CGo wraps imported C functions in stub functions (which perform checks, calling convetion conversion, etc.). Obviously if I pass the address of the CGo wrapper of bar(), it won’t work.

How do I get the pointer to the C function itself? So far I tried some go:linkname tricks but that doesn’t seem to cut it.


submitted by /u/theOtherOtherBob
[link] [comments]

Article Tags:
· ·
Article Categories:

Leave a Reply