-
-
Save alexcrichton/7423809 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
void foo(void(*)()); | |
void bar() { | |
} | |
int main() { | |
foo(bar); | |
return 0; | |
} |
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
extern mod rustuv; | |
use std::rt; | |
use std::ptr; | |
#[no_mangle] | |
pub extern "C" fn foo(c_callback: extern "C" fn()) { | |
do rt::start(0, ptr::null()) { | |
c_callback(); | |
}; | |
} |
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
all: libfoo.dylib bar.c | |
clang bar.c -o bar -L. -lfoo -Wl,-rpath,`pwd` | |
libfoo.dylib: foo.rs | |
rustc --lib foo.rs -Z gen-crate-map | |
ln -nsf libfoo-*.dylib libfoo.dylib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment