Last active
December 10, 2015 00:38
-
-
Save AlekSi/4352551 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct my { | |
void (*f)(); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
/* | |
#include "wrapper.h" | |
*/ | |
import "C" | |
import ( | |
"fmt" | |
) | |
//export goF | |
func goF() { | |
fmt.Printf("Hello from goF\n") | |
} | |
func main() { | |
m := C.generate_my() | |
fmt.Printf("%#v\n", m) | |
m.f() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "wrapper.h" | |
extern void goF(); | |
struct my generate_my() { | |
struct my res = {goF}; | |
return res; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "lib.h" | |
struct my generate_my(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment